Hello everyone, I am going to share the code
sample to get the base URL using ASP.Net MVC and the code detail as given
below.
Please see the example and put your thoughts and
comment as well.
public class ApplicationConfig
{
public static string GetBaseUrlByKey(string key)
{
if (key == Constants.baseURL)
{
}
}
public static string GetBaseUrl()
{
var requestURL = HttpContext.Current.Request;
var appDomainUrl = HttpRuntime.AppDomainAppVirtualPath;
if (!string.IsNullOrWhiteSpace(appDomainUrl))
appDomainUrl += "/";
var baseURL = string.Format("{0}://{1}{2}",
requestURL.Url.Scheme, requestURL.Url.Authority, appDomainUrl);
return baseURL;
}
}
Thank
you!