【发布时间】:2010-06-02 18:57:21
【问题描述】:
我正在使用 ASP.net。我的网站托管在 IIS 根目录下的子文件夹 test 中。所以default.aspx的url是http://localhost/test/Default.aspx。在 default.aspx 中,我想使用带有相对路径的 Reponse.Redirect() 重定向到同一网站内的另一个 url,http://localhost/test/whatever。
我试过了
Response.Redirect("/whatever");
和
Response.Redirect("~/whatever");
他们都重定向到http://localhost/whatever。请注意,Redirect 方法使用 http://localhost 而不是 http://localhost/test/ 作为基本 url。
有什么想法吗?
谢谢。
【问题讨论】:
-
我自己犯了一个愚蠢的错误。 Response.Redirect("~/whatever");应该去localhost/test/whatever。谢谢大家。
标签: asp.net