开发者

Getting browser authentication box after calling Json web service call

Here is my code to call web service from client side code

$.ajax(
                    {
                        type: "POST",
                        url: "counter.asmx/IncreaseCounter",
                        data: "{}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: LogoutSuccess,
                        error: AjaxFailed
                    }
                   );

On my local machine this is working correctly But after production deployment at the time of service call browser popup authentication box appears,which is not allowing me to proceed. I want to get rid of this authentication popup when webservice get called from webpage of my website.

Means I don't want any authentication for this web service.

After some google I added below node in my web.config file but still it s asking me for credentials

<system.web.extensions>
    <scripting>
      <webServices>
        <authenticationService  enabled="false" />
      </webServices>
    </scripting>
  </system.web.extensions>

Please suggest me the solution here is my web service code

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
 [System.Web.Script.Services.ScriptService]
public class counter : System.Web.Services.WebService
{

    public counter()
    {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod(Description = "Per session Hit Counter", EnableSession = true)]
    public void IncreaseCounter(string PostURL)
    {
       string url=  HttpUtility.UrlDecode(PostURL);
       DBAdministrator.Increa开发者_开发问答sePostVisitCount(url);
    }
}


This is extremely odd; either both the page and your service should need authentication or neither.

Since you use relative URLs, loading the page should already pop up the auth box. After that, the user should have a session.

Check two things:

  1. That there is no specific manual configuration for the URL of the service (for example in a proxy between your browser and the server, etc.).
  2. WsiProfiles.BasicProfile1_1 makes me wonder ... what does the constant mean? "Basic" sounds like "basic authentication scheme". Check if there are other values which you can use.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜