if I try to run my program that uses HttpListener without root it throws this exception.
Unhandled Exception: System.Net.Sockets.SocketException: Access denied at System.Net.Sockets.Socket.Bind (System.Net.EndPoint local_end) [0x00000] in :0 at System.Net.EndPointListener..ctor (System.Net.IPAddress addr, Int32 port, Boolean secure) [0x00000] in :0 at System.Net.EndPointManager.GetEPListener (System.Net.IPAddress addr, Int32 port, System.Net.HttpListener listener, Boolean secure) [0x00000] in :0 at System.Net.EndPointManager.AddPrefixInternal (System.String p, System.Net.HttpListener listener) [0x00000] in :0 at System.Net.EndPointManager.AddListener (System.Net.HttpListener listener) [0x00000] in :0
How can I allow HttpListener to be used by users besides root?
If you want it to listen on port 80, it'll need to be started by the root user. If you're okay with it listening on a port > 1024, then any user should be able to start it.
If you want other users to be able to start this listening on port 80, then you'll need to allow them to run it via sudo.