1.符号“/”指程序运行所在根目录,即IIs所在目录。

如果iis所在目录为:d:\programs

解决方案为d:\programs\d

网站路径为:d:\programs\d\web\

符号“/”代表的是:d:\programs,管你的网站前面有多少级,都应该作为一个整体


2.符号“~/”,则是指网站所在根目录。即d:\programs\d\web。

测试代码如下:

protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Write(Server.MapPath("/"));
        Response.Write("<br/>");
        Response.Write(Server.MapPath("~/"));
    }

输出结果:

C:\inetpub\wwwroot\
D:\Programs2008\WebSite2\

 

相关文章:

  • 2022-12-23
  • 2021-07-24
  • 2022-01-18
  • 2021-05-21
  • 2022-12-23
  • 2021-07-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-26
  • 2021-06-15
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案