<p>I have a site behind basic authentication (IIS6).</p>

<p>Part of this site calls a web service that is also part of the site and thus behind basic authentication as well.</p>

<p>However, when this happens the calling code receives a 401 Authentication Error.</p>

<p>I've tried a couple of things, with the general recommendation being code like this:</p>

<pre><code>Service.ServiceName s = new Service.ServiceName();
s.PreAuthenticate = true;
s.Credentials = System.Net.CredentialCache.DefaultCredentials;
s.Method("Test");
</code></pre>

<p>However, this does not seem to resolve my problem.</p>

<p>Any advice?</p>

<p><strong>Edit</strong></p>

<p>This seems to be a not uncommon issue but so far I have found no solutions.
Here is <a href="http://forums.iis.net/t/1146546.aspx" rel="nofollow noreferrer">one thread</a> on the topic.</p>

The Line:
```
```
s.Credentials = System.Net.CredentialCache.DefaultCredentials();
```
```
Maybe you should try :
```
```
s.Credentials = HttpContext.Current.User.Identity;
```
```