Another HTTP Error status 401 problem!!

Discussion in 'ASP .Net Web Services' started by Dale, Jul 14, 2004.

  1. Dale

    Dale Guest

    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
     
    Dale, Jul 14, 2004
    #1
    1. Advertising

  2. Dale

    Dale Guest

    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


    "Dale" <> wrote in message
    news:#...
    > 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
    >
    >
     
    Dale, Jul 15, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UG1jZw==?=

    HttpWebRequest & (401) Unauthorized http status code

    =?Utf-8?B?UG1jZw==?=, Jun 21, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    2,412
    =?Utf-8?B?UG1jZw==?=
    Jun 21, 2004
  2. Sachin
    Replies:
    2
    Views:
    17,899
    Sachin
    Nov 4, 2005
  3. ad
    Replies:
    2
    Views:
    13,531
  4. ad
    Replies:
    0
    Views:
    1,624
  5. raveesh khosa
    Replies:
    1
    Views:
    143
    Simon Hart
    Apr 22, 2006
Loading...

Share This Page