Another HTTP Error status 401 problem!!

D

Dale

I know (or certainly think I remember) that this was working last time I
looked but when I deployed a new version of my project to the development
web server, suddenly I seem to have forgotten everything I knew about web
services authentication. Every attempt to use the service results in a 401
error. I am running the app from IE on my pc, the web server is on another
box, and the web service runs on a third box. Both server boxes run in a
clustered environment.

I have made sure that:

1. anonymous access is off to the ASP.Net and the web services applications
2. <identity impersonate="true"> is on both web.config files
3. in theASP app, I have the line: myService.Credentials =
System.Net.CredentialCache.DefaultCredentials;

I have even tried making a simple client for the default HelloWorld service,
putting them both in the same folder on the web services server, and I get
the same 401 error. The only way to get around the error is enable
anonymous access but then, of course, my code doesn't work because I have no
User.Identity information where I need it for authorization.

What am I missing?

Thanks in advance!

Dale
 
D

Dale

Fixed!!! What a strange one. I didn't realize how significant the
clustering was going to be when I mentioned it in the inital posting.

I don't have all the specific details but what happened is this: The
infrastructure people replaced some load-balancing equipment with a new
Cisco product. Apparently a known issue with this Cisco product is that it
causes the user identity to get lost in a web request. Because I am a
contractor, the infratsructure people didn't know who I was and I didn't see
the email they sent out.

The solution was to create a System.Net.CookieContainer object and assign it
to the CookieContainer property of the web service proxy like this:

// These two lines of code were the fix:
System.Net.CookieContainer cookies = new System.Net.CookieContainer();
myServiceProxy.CookieContainer = cookies;

//and then add the more expected lines:
myServce.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
myService.Proxy.PreAuthenticate = true;

Though not a single item I could find online or on MSDN would give any
indication at all that the CookieContainer property would be used for web
service authentication, and I still don't know the details or internals of
why it is needed, I do know it fixed my elusive Status 401 problem. Perhaps
it will fix yours as well.

Dale
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top