代码如下:public string UTypeCD = "", UTypeNM = "", FilePath = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            FilePath = System.Web.HttpContext.Current.Server.MapPath("/Files/Voteh/201211/");

   <input id="FilePath" type="hidden" value="<%=FilePath %>" />
IIS:在默认网站下建立一个 虚拟目录A现在 在VS中直接运行的话以上路径是对的。
但是通过IIS:http://xxx.xx.xx.xx/A 进行访问的话,FilePath的路径在默认网站下,怎么不是虚拟目录A下?
   

解决方案 »

  1.   

    MapPath("~/路径/");
    这样才能兼容虚拟目录和真实的网站。
      

  2.   

    再请教一下:那么:css中呢?  background: url(../Images/voteItemBG.jpg) no-repeat;取不到图片。。
    及 单独的JS文件中呢: xmlhttp.open("POST", "../Item.aspx?now=" + now + "&type=getTime", false);
            xmlhttp.send(null);
    取不到../Item.aspx。。
    我还是对这个 虚拟路径 头大
      

  3.   

    再请教一下:那么:单独的JS文件中呢: xmlhttp.open("POST", "../Item.aspx?now=" + now + "&amp;type=getTime", false); 这个../Item.aspx好像在IIS中取不到哦
      

  4.   

    css中使用的相对路径 应该是去得到的吧?
      

  5.   

    Server.MapPath("/路径")css中  background: url(Images/voteItemBG.jpg);