How do I get the base URL of My Web Application?

c#, iis-7

Solution

You can use `string baseURL = HttpContext.Current.Request.Url.Host`.

Problem

Is it possible to get the base URL of a web site hosted in IIS 7 by using `Microsoft.Web.Administration.ServerManager`? In the simplest scenario, this would be: ``` http://localhost ``` but I need to get it programmatically. If I can't use `ServerManager` what is the best alternative?

Original source