Using Chrome Developer Tools, how do I tell the cause of "Unexpected response code: 401"?
I'm debugging my ASP.NET MVC 3 web app using Google Chrome Developer Tools, and for some reason, the error "Unexpected response code: 401" gets logged every time a page is loaded. I don't have a clue for which request DevTools is receiving this response, though; I've even inspected the Network
pane in DevTools, without seeing any such response开发者_StackOverflow中文版 from the server. Also, the app appears to work just fine, I can't see the 401 response having any actual effect.
How can I tell in DevTools what causes this response from the server?
With the network pane open, reload the page. Each row in the pane represents a different resource - you can sort the status column by clicking on it. Once you've found your 401, click on the page resource (the left-hand column) to see the request/response details.
From the Wikipedia page List of HTTP status codes:
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
So your root problem is that you either haven't provided authentication details or the details provided weren't accepted.
精彩评论