.net选择错误的根文件夹

时间:2013-07-22 20:42:20

标签: asp.net hyperlink

如果我使用波浪号字符从链接中的根开始,例如在如下图像中: “〜/图像/ image.jpg的” 我的浏览器尝试链接到“default.aspx / images / image.jpg” 为什么呢?

1 个答案:

答案 0 :(得分:1)

在您的web.config中,设置:

<authentication mode="Forms">
    <forms ... defaultUrl="~/" ... />
</authentication>

<强>提醒:

  • / - 网站根
  • ~/ - 应用程序的根目录

不同之处在于,如果您的网站是:

http://example.com

您有一个应用myapp

http://example.com/mydir/myapp

/将返回网站的根目录(http://example.com),

~/将返回应用程序的根目录(http://example.com/mydir/)。