C#取得站点跟目录

string strServer = "http://" + Request.ServerVariables["SERVER_NAME"].ToString();
 string strPort = ":" + Convert.ToString(Request.ServerVariables["SERVER_PORT"]);
 string strRoot = Request.ApplicationPath + "/";
 if (strPort.Trim() == ":80")
 {
      strPort = "";
 }
 string strUrl = strServer + strPort + strRoot;

原文地址:https://www.cnblogs.com/taiyonghai/p/5604266.html