问题
I have a localhost port based web page (a web service using the ASP.NET Development Server - MSVS2k8 WebDev.WebServer.exe
) that works correctly when accessed via a browser (either Chrome 35 or IE 11), but it is currently failing when I access it via WebClient
(via DotLisp or LinqPad) or MSTest.
This is on a Win8.1 64-bit machine, still using Visual Studio 2008.
I have rebooted but the problem remains, even though this was working earlier today. I have also ran Visual Studio as Administrator and not.
Details:
Exception: System.Net.WebException Message: The remote server returned an error: (401) Unauthorized. Target: Byte[] DownloadDataInternal(System.Uri, System.Net.WebRequest ByRef) Source: System
Simplified calling code:
(def (get-web-page url)
(with-dispose
(wc (WebClient.)
b (wc.DownloadData url)
m (MemoryStream. b false)
s (StreamReader. m))
s.Peek
s.ReadToEnd))
LinqPad:
Using wc = New WebClient
Dim twp = wc.DownloadString("http://localhost:20147/")'TestServers.aspx")
twp.Dump
End Using
(I also have a problem when using Run Test instead of Debug Test, where the attempt to update assemblies for Code Coverage or something related to that is failing in "interesting" ways. But I believe this is unrelated to the above problem, except that attempting to solve this issue may have somehow caused me to change the settings that caused the above issue.)
回答1:
I don't know how the settings changed, and/or why it was working earlier otherwise, but turning off NTLM Authentication fixes the problem.
Specifically, right clicking the web project in the Solution Explorer > Property Pages > Start Options and uncheck NTLM Authentication and click OK.
来源:https://stackoverflow.com/questions/24575177/asp-net-development-server-unexpected-authentication-required