![](https://i-blog.csdnimg.cn/blog_migrate/2f60c0bc47d4178ac5e2b807936153ff.gif)
其实也很简单,用到了ServerVariables集合
protected string GetVirtualPath()
{
string strServer = Convert.ToString(Request.ServerVariables["SERVER_NAME"]);
string strPort = Convert.ToString(Request.ServerVariables["SERVER_PORT"]);
string strRoot = Request.ApplicationPath;
if (strPort == "80")
strPort = "";
return string.Format("