You have many options:
string root = this.ResolveUrl("~")
or
Uri requestUri = Context.Request.Url;
string baseUrl = requestUri.Scheme + Uri.SchemeDelimiter + requestUri.Host + (requestUri.IsDefaultPort ? "" : ":" + requestUri.Port);
Or
string baseUrl = Request.Url.GetLeftPart(UriPartial.Authority);
If you want to add / blog to the last two, add
+ Request.ApplicationPath
source
share