說裏面的Response.Redirect例外,我有一個try/catch塊某處封裝了一大塊代碼,然後在裏面我需要調用的Response.Redirect這樣:的try/catch塊
protected void ButtonGo_Click(object sender, EventArgs e)
{
try
{
using(lockingMethod)
{
//Code...
//Somewhere nested in the logic
Response.Redirect(strMyNewURL);
//More code...
}
}
catch(Exception ex)
{
LogExceptionAsError(ex);
}
}
在這種情況下會發生什麼是Response.Redirect
引發異常,關於終止線程,我相信這是該方法的「正常事件流」,但它會作爲錯誤記錄在我的LogExceptionAsError
中。所以我很好奇,有什麼辦法可以讓Response.Redirect
不會拋出異常?
strMyNewUrl的值是什麼? –
可能的重複[有什麼阻止Response.Redirect在try-catch塊內工作嗎?](http://stackoverflow.com/questions/1063625/is-there-something-that-prevents-response-redirect-to -work-inside-try-catch-bloc) –
@AmitSingh:我項目中的其他頁面。我不確定你爲什麼需要它? – c00000fd