private string GetPath()
{
  return Server.MapPath("");
}
不是很方便吗?

解决方案 »

  1.   

    谢谢两位的回答,但是Server.MapPath所返回的是应用程序在服务器的物理地址。得到的数据是将是:c:\intput\wwwroot\aa,而不是我所需要的
    HTTP://CSDN.NET/AA
      

  2.   

    try to combine (did not test, so there might be oversight)Request.ServerVariables["SERVER_NAME"]
    and
    Request.ServerVariables["SCRIPT_NAME"] or Request.ServerVariables["URL"] 
      

  3.   

    谢谢楼上回答,你所提供的方法在ASPX文件中可以用,但是在GLOBAL.ASAX文件中就不能用了.因为Request.ServerVariables必须有用户请求才能返回数值,而GLOBAL.ASPX本身并没接到用户的具体请求
      

  4.   

    Application_Start runs only once when a request is made, it does not run on its own. After that, unless you restart the server or modify global.asax, it will not run again