Question

I have a web service that uploads documents to Sharepoint and works fine using

System.Net.ICredentials creds = System.Net.CredentialCache.DefaultCredentials;
context.Credentials = creds;

I have re-used this code in another project and I get the error:

System.Net.WebException was unhandled by user code
Message=The remote server returned an error: (401) Unauthorized.

As far as I can see everything is the same in the config files and don't know why its failing. Any ideas?

Was it helpful?

Solution

I solved it for anyone who might come across a problem like this.

The problem is in IIS, it is using the default application pools. Simply change it from default to your custom pool where the "Identity" field is your PC name or Login Credentials. This can be done to the default App pool, however, if you have existing projects using this pool, it is advisable to create a new App pool so you don't break existing projects.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top