Search code examples
web-servicesasmxhttp-status-code-401unauthorized

Rare and sporadic 401 Unauthorized error with ASMX / WCF web service using Windows Authentication


We have a hybrid WCF and ASMX web service currently being used on a decent sized project. Now, most of time everything works perfectly fine, however on rare occasions and seemingly randomly, the web service begins to block calls which returns a 401 Unauthorized error back to the page in question. It seems to be the ASMX service calls that are causing this, but given that's it doesn't occur often and isn't reproducible I can't say this for certain.

The error goes away after an IIS reset, and at least on one occasion it eventually just went away on it's own. We use Windows Authentication as the credential type with anonymous access disabled.

Anyone have any ideas about why this might be occuring?


Solution

  • The solution we finally figured out was a small registry edit to disable the loopback check that causes the login issues with IIS. We had actually had this registry edit floating around but had forgotten about it over time.

    The key is located at:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
    

    Add a DisableLoopbackCheck DWORD with a value of 1 and that seems to take care of the problem

    MS Support link: http://support.microsoft.com/kb/896861