ASP.NET AJAX and Forms Authentication generate a HTTP 401 sporatically

Last post 11-06-2009 3:30 AM by pmourfield. 3 replies.

Sort Posts:

  • ASP.NET AJAX and Forms Authentication generate a HTTP 401 sporatically

    11-04-2009, 9:28 PM
    • Member
      652 point Member
    • pmourfield
    • Member since 10-11-2005, 10:06 AM
    • Posts 109

    I have a situation where I'm using clientside ASP.NET AJAX requests to a WebService in the same web site. The WebService folder is protected by FormsAuthentication. It seems to work fine, execpt when I load test the website using VS2008 Test Edition, a majority of the web service calls are generating HTTP 401 responses.  Any ideas what I can look at?

    Thanks! 

    Sincerely,
    Peter Mourfield
    www.mourfield.com

    Please remember to click “Mark as Answer” on the post that helps you.
  • Re: ASP.NET AJAX and Forms Authentication generate and HTTP 401 sporatically

    11-04-2009, 9:37 PM
    Answer
    • All-Star
      30,595 point All-Star
    • HeartattacK
    • Member since 01-08-2007, 5:53 PM
    • Dhaka, Bangladesh
    • Posts 3,306
    • Moderator
      TrustedFriends-MVPs

    Do your tests perform authorization before trying to access the service? A 401 is an error code denoting  unauthorized access:

    "401 Unauthorized Similar to 403 Forbidden, but specifically for use when authentication is possible but has failed or not yet been provided.[2] The response must include a WWW-Authenticate header field containing a challenge applicable to the requested resource"

    Make sure that authorization is performed by the tests, or disable forms authentication during testing.

     

    All that glitters is gold-
    Only shooting stars break the mold.

    Read my blog: www.heartysoft.com

    Tell me what tutorials / articles / videos you want to see on my site.
  • Re: ASP.NET AJAX and Forms Authentication generate and HTTP 401 sporatically

    11-06-2009, 3:29 AM
    • Member
      652 point Member
    • pmourfield
    • Member since 10-11-2005, 10:06 AM
    • Posts 109

    Yes, my tests are doing authorization. The tests work fine when running them with a single user. It's only when I put the sure under a load that these 401 errors start popping up. When they do happen, it's not for every test. 

    Sincerely,
    Peter Mourfield
    www.mourfield.com

    Please remember to click “Mark as Answer” on the post that helps you.
  • Re: ASP.NET AJAX and Forms Authentication generate a HTTP 401 sporatically

    11-06-2009, 3:30 AM
    Answer
    • Member
      652 point Member
    • pmourfield
    • Member since 10-11-2005, 10:06 AM
    • Posts 109

    To solve this issue, I removed the WebService directory from FormsAuthentication using the <location> tag in the web.config. I then rewrote the WebService to do it's own user verification in code. 

    Sincerely,
    Peter Mourfield
    www.mourfield.com

    Please remember to click “Mark as Answer” on the post that helps you.
Page 1 of 1 (4 items)