A small example in ES0en. net of getting the application's full Url path

  • 2020-06-07 04:25:04
  • OfStack


/// <summary> 
/// Gets the absolute root 
/// </summary> 
public static Uri AbsoluteWebRoot 
{ 
    get  www.ofstack.com
    { 
        var context = HttpContext.Current; 
        UriBuilder uri = new UriBuilder(); 
        uri.Host = context.Request.Url.Host; 
        if (!context.Request.Url.IsDefaultPort) 
        { 
            uri.Port = context.Request.Url.Port; 
        } 

        uri.Path = VirtualPathUtility.ToAbsolute("~/"); 

        Uri absoluteWebRoot = uri.Uri; 

        return absoluteWebRoot; 
    } 
} 


Related articles: