asp.net 获取当前项目的根目录路径

获取网站根目录的方法有几种如:

Server.MapPath(Request.ServerVariables["PATH_INFO"])
   Server.MapPath("/")

   Server.MapPath("~/")//当前代码文件所在的目录路径
   Server.MapPath("")//当前代码文件所在的目录路径
   Server.MapPath(".")
   Server.MapPath("../")
   Server.MapPath("..") 

      Page.Request.ApplicationPath

System.Web.HttpContext.Current.Request.PhysicalApplicationPath

和Server.MapPath("~/")效果是一样的。

Server.MapPath("~/");//无论代码所在的文件的、页面路劲是什么,永远返回 C:InetpubwwwrootEnglishClub(就是当前程序运行的所在根目录)