This website may use cookies. More info. That's Fine x
Welcome Login

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


Visual Studio

Problem:

Error message: unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

 

vs-redirectex1

 

This error normally occurs when you use Response.Redirect, Server.Transfer or Response.End in your code before completing the actual process the page was doing.

 

Solutions:

a. In place of Response.End, use HttpContext.Current.ApplicationInstance.CompleteRequest

 

b. In place of Response.Redirect(url), use:

Response.Redirect(url, false);

Where:

Redirect()'s second parameter (bool) indicates whether execution of current page should terminate.

 

c. In place of Server.Transfer, use Server.Execute method

 

 

For more information, see here.


Created on: Tuesday, March 27, 2012 by Andrew Sin