Published Wednesday, July 19, 2006 2:55 AM by martin

URLs, ACLs and netsh.exe

Running a WCF service with an http endpoint on Windows Vista, when you open your service host (non-IIS) you might see an exception something like this...

"The ChannelDispatcher at '<url>' with contract(s) "<contract>" is unable to open its IChannelListener"

...with an InnerException (a couple of levels deep) something like...

"Cannot access a disposed object\r\nObject name: 'System.Net.HttpListener'."

What this exception is struggling to tell you is that you need to be running elevated in order to listen on the URL(s) you're requesting.  So you could just "run as administrator", but in general you'd rather not, right?  Here's where netsh.exe comes in.

Let's say I want my service to listen at http://localhost:8888/MyService.  I can "reserve" the url for a particular user account (or group) as follows...

netsh http add urlacl /url=http://+:8888/MyService /user=DOMAIN\user

Then, not only do I not need to be elevated, but my account doesn't need any administrative rights at all.  I guess it goes without saying, though, that I do need to be elevated when I run netsh.exe.