Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

asp.net

whenever i Response.Redirect("myexamplepage.aspx"); it either keep looping and then lastly show the page is unable to view or show this above error. However, if i Response.Redirect("http://www.google.com.sg"); it works.

I tried all the methods i found online such as the following:

  1. Response.Redirect(url,false)
  2. Redirecting url outside the try-catch

I'd also make sure that my project is running debug mode.

BUT i am still facing this problem. It is like so random because previously i dont have any problems redirecting to my url. Please provide me with solutions thanks.


2 Answers

This error occures most of the time when you are trying to redirect to a new page, while the current page is still trying to complete it's proces.

You can find more information about the issue right here:

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

So change your code to the following:

HttpContext.Current.ApplicationInstance.CompleteRequest();
Response.Redirect ("myexamplepage.aspx", false);
like image 69
Rob Angelier Avatar answered Nov 25 '25 12:11

Rob Angelier


As Rob Angelier said, the problem is related to an uncompleted process. That means, make sure you move the Response.Redirect out of the using statement!

This may not be an actual answer to the specific question but I thought it would help others struggling with the same type of problem :)

like image 36
Nurp Avatar answered Nov 25 '25 11:11

Nurp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!