Tags

, ,


Today I tried to debug the following code and it works but throws the following exception:

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

Code:

if (!IsInputValid())
{
  return;
}
try
{
  SaveSelection();
  //return back the last access page
  Response.Redirect(LastUrl());
}
catch (Exception err)
{
  lblMsg.Text = "Failed to Save TimeZone - " + err.Message;
}

Searched and I find the solution is the following: (Related post:http://forums.asp.net/t/984756.aspx/1 )

Exception help from microsoft: http://support.microsoft.com/kb/312629/EN-US/

Solution:

  1. Use the Response.Redirect(url, false);
  2. Move the Response.Redirect code out of control
Advertisements