The request failed with HTTP status 401: Unauthorized.


Kevin Burton

I have a web service that has been working before but now I am getting:

The request failed with HTTP status 401: Unauthorized.

This is to the localhost and I am a member of the administrators group for
this machine so I am not sure what is unauthorized nor do I understand how to
find out why I am getting this error (exception). Any ideas?

Thank you.

Kevin Burton



Bruce Johnson

Does the virtual directory that hosts the web service allow anonymous
access? If not, then you have two choices. Configure the virtual
directory to allow anonymous access. Or assign the
System.Net.Credentials.DefaultCredentials to the Credentials property on
the proxy object that you're using the call the web service.

Hope that helps.

Bruce Johnson [.NET MVP]



Mohamed El Ashmawy

Does the webservice use imperonation?
If not, then the process for it would run under the identity of "ASPNet"
account. (Not your account as administrator).
Does the code of web service use resources (file access, database access,
etc.) on the machine? If it does so, then you need to give ASPNet account
the needed permissions on them (if you are not using impersonation).

Mohamed El Ashmawy
MEA Developer Support Center
ITWorx on behalf of Microsoft EMEA GTSC