Does HttpListener work well on Mono?

前端 未结 2 711
渐次进展
渐次进展 2020-12-28 16:20

I\'m looking to write a small web service to run on a small Linux box. I prefer to code in C#, so I\'m looking to use Mono.

I don\'t want the overhead of running a f

2条回答
  •  攒了一身酷
    2020-12-28 16:51

    Greetings, The HttpListener class in Mono works without much of a problem. I think that the most significant difference between its usage in a MS environment and a Linux environment is that port 80 cannot be bound to without a root/su/sudo security. Other ports do not have this restriction. For instance if you specify the prefix: http://localhost:1234/ the HttpListener works as expected. However if you add the prefix http://localhost/, which you would expect to listen on port 80, it fails silently. If you explicitly attempt to bind to port 80 (http://localhost:80/) then you throw an exception. If you invoke your application as a super user or root, you can explicitly bind to port 80 (http://localhost:80/).
    I have not yet explored the rest of the HttpListener members in enough detail to make any useful comments about how well it operates in a linux environment. However, if there is interest, I will continue to post my observations.

    chickenSandwich

提交回复
热议问题