I need to be able to fetch the web port being used by my MVC instance on startup, as it may change from site to site. Most answers to how to fetch the port involve getting it from the request object, which doesn't exist in Application_Start. Is there any other way to fetch it?
I tried to fetch it like so:
HttpContext.Current.Request.ServerVariables["SERVER_PORT"]
But this throws an exception
"System.Web.HttpException (0x80004005): Request is not available in this context"