2012年10月2日星期二

C# HttpListener Access Denied when start on Windows 7

netsh http add urlacl url=http://+:80/MyUri user=DOMAIN\user

This is helpful, but for completeness, the URL specified in this line of code: httpListener.Prefixes.Add("http://*:4444/"); must match EXACTLY with the one in the netsh command. For example, I had httpListener.Prefixes.Add("http://127.0.0.1:80/"); and the same netsh command you have, and the HttpListenerException will still be thrown. I needed to change httpListener.Prefixes.Add(http://+:80/);

http://stackoverflow.com/questions/4019466/httplistener-access-denied-c-sharp-windows-7