Thursday, February 11, 2010

ASP.NET: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.


protected void btn1_OnClick(object sender, EventArgs e)
{
try
{
//Do some coding here...

Response.Redirect("default2.aspx");
}

catch (Exception ex)
{
//handle event exception. write error to log file.
}
finally
{
//some coding. like colsing connection.
}
}

In this kind of coding, above error will be displayed. Reason there are codes to execute after redirecting page. To avoid this problem use following code.

Response.Redirect("default2.aspx",false);

No comments:

Learning Video...

Loading...