1

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.)

Mark Hurd
  • 10,665
  • 10
  • 68
  • 101
  • This was hard to debug, even once I stopped trying to get the automated testing working, because of the Win8.1 automatic bypass of proxy for `localhost` meant it was a little difficult to get Fiddler to confirm what was different between Chrome and IE hitting the page and the .NET WebClient. – Mark Hurd Jul 04 '14 at 13:16

1 Answers1

2

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.

Mark Hurd
  • 10,665
  • 10
  • 68
  • 101