Is it possible to host an OWIN web app (via WebApp.Start()
or some other method) on a random port. I've looked at solutions like this (1) which use TcpListener
to find a random port, or progressive scanning techniques like this (2), but it would be great if you could just do something like WebApp.Start("http://localhost:0")
and be able to inspect the actual port binding.
To clarify: my issue with (1) is that the port is bound, then released, then rebound by the WebApp.Start
method, and the second binding may fail inbetween (i.e. race condition). My issue with (2) is the potential inefficiency (although I have nothing to base this gut feeling on)