I pursued the problem and decided to make the most basic reproduction of the problem possible in the hope that a simplified question would help me solve this problem.
I get 401 when sending to a web service via ajax in javascript. I will include as much information as possible, as well as all the troubleshooting steps that I have tried.
I created a test page at the root of my site and tried both simple JS and jquery to call ajax with the same results. I included jquery comment ...
Page
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//" "http://www.w3.org/TR/html4/loose.dtd"> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script> <script type="text/javascript"> function runAjax() { </script> </head> <body> <div id="myDiv"> <table width="100%" cellpadding="3" cellspacing="0"> <tbody> <tr> <td width="34%"> <div align="right"> <strong>First Name: </strong> </div> </td> <td> <div> <input name="First_Name" type="text"id="First_Name" size="20"> </div> </td> </tr> <tr> <td> <div align="right"> <strong>Last Name: </strong> </div> </td> <td> <input name="Last_Name" type="text" id="Last_Name" size="20"> </td> </tr> </tbody> </table> <div align="center"> <input id="button" type="button" value="Update Student Details" onclick="runAjax();" style="margin:5px;"> </div> </div> </body> </html>
Now in every browser except IE10, this works fine. In fiddler, this shows that IE gets a 401 response
Fiddler request header
POST http://dev.mysite/service/name/service.aspx/ChangeName HTTP/1.1 Accept: */* Content-Type: application/json; charset=utf-8 Referer: http://dev.mysite/test_page.html Accept-Language: en-US Accept-Encoding: gzip, deflate User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0) Connection: Keep-Alive Content-Length: 46 DNT: 1 Host: dev.mysite Pragma: no-cache {"ID":"2","firstName":"John","lastName":"Doe"}
Fiddler response headers
HTTP/1.1 401 Unauthorized Content-Type: application/json; charset=utf-8 Server: Microsoft-IIS/7.0 jsonerror: true WWW-Authenticate: Negotiate WWW-Authenticate: NTLM X-Powered-By: ASP.NET Date: Thu, 07 Mar 2013 01:12:05 GMT Content-Length: 105 Proxy-Support: Session-Based-Authentication
I turned on Failed Request Tracing on the server, and this is the information he gave me for this call:
Iis failed request log
1. -GENERAL_REQUEST_START
2. -FILTER_START
- FilterName - C: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ aspnet_filter.dll
3. -FILTER_END
4. -AspNetStart
- ConnID - 0
- The context identifier is {00000000-0000-0000-6425-0080000000BF}
- Data1 - POST
- Data2 - / service / name / service.aspx
- Data3 -
5. -GENERAL_REQUEST_END
- BytesSent - 359
- BytesReceived - 440
- HttpStatus - 401
- HttpSubStatus - 0
The things that I found simplifying the ajax request was that it was not only a Windows 8 issue, but that the compatibility mode was not working.
I tried disabling kernel-mode authentication in IIS, I checked the permissions in the web services folder three times, followed these suggestions , I even tried placing the web service in the same directory as the page. All with the same result ... Any direction or help is welcome.