How can I get the baseurl of site?

后端 未结 12 1644
借酒劲吻你
借酒劲吻你 2020-11-30 17:43

I want to write a little helper method which returns the base URL of the site. This is what I came up with:

public static string GetSiteUrl()
{
    string ur         


        
12条回答
  •  旧巷少年郎
    2020-11-30 17:57

    Try this:

    string baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority + 
        Request.ApplicationPath.TrimEnd('/') + "/";
    

提交回复
热议问题