문제

The setting: Windows 7, IIS installed and running.

The following piece of code:

HttpListener listener = new HttpListener();
listener.Prefixes.Add("http://server.com:8080/path");
listener.Start();

Works like charm - any request made against the server is received in my code.

However, when I make the following change (moving to port 80) http.sys/IIS (not sure which) returns HTTP 503 errors:

listener.Prefixes.Add("http://server.com:80/path");

I've tried setting URLACLs, running this process as admin, etc., but nothing changes this behavior.

Edit: to clear this out - there is not actual networking involved in this mess. All this is done locally on a single machine, for testing purposes (both server and client).

Any ideas?

도움이 되었습니까?

해결책

ok, not sure why, and I hate such answers, however... the problem went away. I can verify that no code was changed, and it wasn't the transient state of the machine in question as I tried rebooting it more than once during the problem trials.

I have no idea what caused it.

다른 팁

I observed the same on a Windows Server 2008 R2 machine. I developped my listener initially on port 8080 which most samples use, then switch to port 80. The first time I ran on port 80, I got either the IIS start page (IIS role is not installed on my server currently, may be an IE cache issue) or a blank page. I had breakpoints in the handler and could see the requests coming through and being answered to successfully. After re-compiling (clean), re-installing my service and restarting IE, the issue was gone. No code change.

So if you hit that issue, try recompile clean, re-install your service (or app) and restart IE.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top