## venerdì 15 ottobre 2010

### Error calling a WebService method: "The request failed with HTTP status 401: Unauthorized."

If you get the error "The request failed with HTTP status 401: Unauthorized." when calling a .net web service running in IIS you must set the following properties in the calling application:

var ws = new localhost.WebService();

ws.Credentials = CredentialCache.DefaultCredentials;
ws.PreAuthenticate = true;

These settings will let you connect to the service.
If you need to you can manually specify credentials or use the credentials of the the calling application.