Error: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack
Cause of Error:
When we call Response.Redirect("") from try/catch block in asp.net, you will receive above error.
Example contains error:
try
{
string strRedirectUrl = Session["ReturnUrl"].ToString();
Response.Redirect(strRedirectUrl);
}
catch(Exception ex)
{
Response.Redirect("Default.aspx");
}
Solution:
Make second argument of response.redirect("MyPage.aspx",false);
Example containing solution:
try
{
string strRedirectUrl = Session["ReturnUrl"].ToString();
Response.Redirect(strRedirectUrl,false);
}
catch(Exception ex)
{
throw ex;
}
No comments:
Post a Comment