Asp.net
使用 Response.Redirect() 到相對路徑
我正在使用 ASP.net。我的網站託管在
testIIS 根目錄下的子文件夾中。所以 default.aspx 的 url 是http://localhost/test/Default.aspx. 從 default.aspx,我想使用Reponse.Redirect()相對路徑重定向到同一網站內的另一個 urlhttp://localhost/test/whatever,.我試過了
Response.Redirect("/whatever");和
Response.Redirect("~/whatever");他們都重定向到
http://localhost/whatever. 請注意,該Redirect方法使用http://localhost而不是http://localhost/test/作為基本 url。有任何想法嗎?
謝謝。
嘗試:
Response.Redirect("hello");還
Response.Redirect("./hello");享受!
抱歉,如果我過度簡化或誤解了您的問題,但您是否嘗試過:
Response.Redirect("hello");