0
我想重定向到使用Server.Transfer的另一頁,我有這個簡單的代碼:Server.Transfer不起作用?
if (Page.IsPostBack)
{
try
{
Server.Transfer("AnotherPage.aspx");
}
catch (Exception)
{
throw ;
}
}
但我發現了一個錯誤:「對於AnotherPage.aspx執行錯誤子請求」。無法在網上找到解決方案。
只要提一下,Response.Redirect完美無瑕。
在瀏覽器中轉到AnotherPage.aspx時會發生什麼?它工作嗎?它在同一個文件夾/路徑中嗎? – 2010-05-11 07:49:24
你實際上只是試圖將用戶重定向到新頁面嗎?如果是這樣,請使用Response.Redirect()而不是Server.Transfer()。如果AnotherPage.aspx上存在錯誤,在使用Response.Redirect()*或*之後,它們會變得很清晰,直接從瀏覽器導航到AnotherPage.aspx。 – Richard 2010-05-11 07:51:11
當你移除try/catch塊時會發生什麼?在這裏吃例外是沒有意義的,然後問什麼是錯的。 – 2013-04-19 04:41:55