Answer the question
In order to leave comments, you need to log in
How to get the absolute url of an ASP.NET MVC application?
How to get the absolute url of the application, taking into account ports and protocol, without using Request? Those if I test on local should get localhost: 55039 if I hosted the application then https://toster.ru/
Answer the question
In order to leave comments, you need to log in
There is only HttpContext.Current in Application_Start. It's just not clear what you want. If you have some environment settings that depend on the mode of operation (under debugging or combat), then there are simpler solutions for this - Web.Debug.config , Web.Release.config
Alternatively, you can use Application_BeginRequest instead of Application_Start()
protected void Application_BeginRequest(object sender, EventArgs e)
{
var current = HttpContext.Current.Request.Url.AbsoluteUri;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question