如何得到当前服务器的域~!如有
A:http://localhost/        根站点
B:http://localhost/xdc/    此为虚拟站点在B站点中有怎么得到B站点的URL :http://localhost/xdc/ 用Request.ServerVariables("HTTP_HOST")只能得到 localhost
问题是我现在要怎么样才能得到此站点的虚拟站点~:http://localhost/xdc/

解决方案 »

  1.   

    Server.MapPath(".");
    只能得到当前的物理路径~!
    如c:\wwwroot\xdc问题是我要得到
    http://localhost/xdc
    该怎么实现?
      

  2.   

    要得到的是网站的URL不是物理地址,
      

  3.   

    如何得到当前服务器的域~!如有
    A:http://localhost/        根站点
    B:http://localhost/xdc/    此为虚拟站点在B站点中有怎么得到B站点的URL :http://localhost/xdc/ 用Request.ServerVariables("HTTP_HOST")只能得到 localhost
    问题是我现在要怎么样才能得到此站点的虚拟站点~:http://localhost/xdc/
      

  4.   

    我是在 web.config里定义
    把<add key="SYS_VirtualDirectory" value="supervise" /> <!--服务器虚拟目录-->
    supervise为你自己虚拟目录文件夹
    然后读取。
      

  5.   

    Request.ApplicationPath
    或者直接使用~/
      

  6.   

    如果地址栏是:http://localhost/xdc/
    那么用:
    "http://" + Request.ServerVariables("HTTP_HOST") + "/" + Request.ServerVariables("URL")就可以了,如果可能是https,那么就判断一下Request.ServerVariables("HTTPS")等于on还是off如果是on,就是:
    "https://" + Request.ServerVariables("HTTP_HOST") + "/" + Request.ServerVariables("URL")
      

  7.   

    string Dir = string.Format("{0}{1}",System.Web.HttpContext.Current.Server.MapPath("/."),System.Web.HttpContext.Current.Request.ApplicationPath);
    Response.Write(Dir);
      

  8.   

    using System.DirectoryServices;