Sunday 24 March 2013

Getting Exception 1

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


Happens when :

If you use the Response.End, Response.Redirect, or Server.Transfer method, a ThreadAbortException exception occurs. You can use a try-catch statement to catch this exception.

Why does this happen??

The Response.End method ends the page execution and shifts the execution to the Application_EndRequest event in the application's event pipeline.
The line of code that follows Response.End is not executed.
 This problem occurs in the Response.Redirect and Server.Transfer methods because both methods call Response.End internally.


What Should I do?

Add the second paramter for Response.Redirect , Server.Transfer to false.

 Response.Redirect ("nextpage.aspx", false);
Noticed in:

  • Microsoft ASP.NET 4.5
  • Microsoft ASP.NET 4
  • Microsoft ASP.NET 3.5
  • Microsoft ASP.NET 2.0
  • Microsoft ASP.NET 1.1
  • Microsoft ASP.NET 1.0
  • No comments:

    Post a Comment