How can I create an HttpListener class on a random port in C#?

后端 未结 7 1462
广开言路
广开言路 2020-12-03 16:34

I would like to create an application that serves web pages internally and can be run in multiple instances on the same machine. To do so, I would like to create an H

7条回答
  •  抹茶落季
    2020-12-03 17:13

    I do not believe this is possible. The documentation for UriBuilder.Port states, "If a port is not specified as part of the URI, ... the default port value for the protocol scheme will be used to connect to the host.".

    See https://msdn.microsoft.com/en-us/library/system.uribuilder.port(v=vs.110).aspx

提交回复
热议问题