Alternative to HttpListener?

Regarding the statement:

I've recently discovered that HttpListener needs to be run as Administrator

That's not entirely true and some of the other answers touch on one of the reasons, but there is another:

  1. Noted by other posters: You can grant permissions to a non-Administrator. Fine, but not great.
  2. You can listen on localhost, even on port 80, without being an admin. Note: I recall that only "localhost" works and not "127.0.0.1"... so be sure that you pass localhost to your Prefixes.Add call.

We're shipping an internal tool that allows developers to run an HTTP-based app host on their PCs and we at first thought using HttpListener would not be possible due to the Admin (or Admin-granted permissions) problem, but then we found that localhost works just fine without being an Admin. It sort of makes sense: listening externally is "dangerous" but listening on the local machine is not quite as dangerous.


One alternative that I've found is C# Webserver on CodePlex.

"... a flexible http server which can be embedded in any .Net application. It has a modular design where features are added using modules. The server also supports REST and all http verbs ..."

It has an HttpListener class which I imagine is similar to System.Net.HttpListener, but I haven't used either one of them yet so I can't be certain.


Like the comment by Will Dean on your post says, you could run the following netsh command:

netsh http add urlacl url=http://+:8346/ user="NTAuthority\Authenticated Users" sddl="D:(A;;GX;;;AU)"

Substitute the 'http://+:8346/' with your value, and this will allow any authenticated user to run the webserver at the target endpoint.


One solution to this is covered by this other question - you can give yourself permissions to run HttpListener as a non-admin.

You could get the app to be started from a command file that sorts out the permissions and then runs the real app.