.net中获取应用程序完整Url路径的方法
2012-10-25 16:07:39 来源:WEB开发网核心提示: /// <summary>/// Gets the absolute root/// </summary>public static Uri AbsoluteWebRoot{get{var context = HttpContext.Current;UriBuilder uri = new U
/// <summary>
/// Gets the absolute root
/// </summary>
public static Uri AbsoluteWebRoot
{
get
{
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;
}
}
更多精彩
赞助商链接