The request failed with HTTP status 401: Access Denied. error when accessing .net webservice

Can some one please tell me why im getting this error.


Answer this question

The request failed with HTTP status 401: Access Denied. error when accessing .net webservice

  • JeanL

    Looks like you have authentication turned on at the server and your client is not passing the right credentials.



  • cka11

    You are getting this error because your web service needs Authentication and you are not providing the same when you access the web service.

    The Two solutions for the above problem is

    1. Enable the anonymous access of the Virtual directory in the IIS (inetmgr.exe) for the folder
    2. Considering the name of the WebService object is service1, provide the following lines to provide the authentication to the accessing application.

    C#

    Service1.PreAuthenticate = true;

    Service1.Credentials = System.Net.CredentialCache.DefaultCredentials;

    VB.Net

    webService.PreAuthenticate = True

    webService.Credentials = System.Net.CredentialCache.DefaultCredentials

    This should reslove your problem.



  • The request failed with HTTP status 401: Access Denied. error when accessing .net webservice