C#实现设置完整虚拟路径

//路径访问绝对地址
string servername = HttpContext.Current.Request.ServerVariables["SERVER_NAME"];
string port = HttpContext.Current.Request.ServerVariables["SERVER_PORT"];
StringBuilder mHttpUrl
= new StringBuilder();
mHttpUrl.Append(
"http://");
mHttpUrl.Append(servername);
if (port.Length > 0)
{
    mHttpUrl.Append(
":");
    mHttpUrl.Append(port);
}
string mServerName = "~/AppModules/Archives/HTMLIMAGE/index.htm";
mHttpUrl.Append(
this.Page.ResolveUrl(mServerName));

posted @ 2014-02-26 19:24  zzg168  阅读(157)  评论(0编辑  收藏  举报