0

I have a service hosted on http://127.0.0.1:2113/ and have made the following URL registration in http.sys

http://*:2113/

However, for some reason the service throws the exception

System.Net.HttpListenerException (0x80004005): Access is denied
HTTP async server failed to start listening

If I also add the URL registration

http://127.0.0.1:2113/

to http.sys, then it works. The same scenario unfolds, if I host the service on http://localhost:2113/

Can anyone explain this? I've read about wildcard registrations in http.sys and from what I can understand, it should match these addresses too. Perhaps I should add, that I've double-checked that I don't have any other registrations on port 2113.

SabrinaMH
  • 221
  • 1
  • 3
  • 11

1 Answers1

0

The address you register with netsh.exe (http://*:2113/) must exactly match the address you give to HttpListener, that's an http.sys requirement.

Tratcher
  • 5,929
  • 34
  • 44
  • Thanks for the clarification. I found documentation regarding wildcards (both * and +) here: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364698(v=vs.85).aspx But according to your answer, this doesn't apply to http.sys registrations? – SabrinaMH Aug 30 '17 at 06:08
  • You can use wildcards in your registration, but then you must use the same wildcard when you start HttpListener. The wildcard rules you linked to are about what happens when you have multiple registrations/apps. – Tratcher Aug 31 '17 at 05:09