I often forget the correct syntax to find the current URL, so I posted it to remember it... Always usefull
Request.Url.AbsoluteUri
public static string BaseSiteUrl
{
get
{
HttpContext context = HttpContext.Current;
string baseUrl = context.Request.Url.Scheme + "://" + context.Request.Url.Authority + context.Request.ApplicationPath.TrimEnd('/') + '/';
return baseUrl;
}
}
OR
public string BaseSiteUrl()
()
{
if(HttpContext.Current.Request.ApplicationPath == "/")
return "http://" + HttpContext.Current.Request.Url.Host;
else
return "http://" + HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.ApplicationPath;
}
intersting link:
More to come
fdbfc5e0-fd99-4a43-883f-2910606eb952|0|.0
Tags: