当前位置:编程学习 > asp >>

Asp.net中获取应用程序完整Url路径的方法

 
[csharp] 
/// <summary> 
/// Gets the absolute root 
/// </summary> 
public static Uri AbsoluteWebRoot 

    get  www.zzzyk.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; 
    } 

补充:Web开发 , ASP.Net ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,