Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack
Hi, This one's trick with Response.Redirect() .
Solution 1:
For better understand what happens if use Response.Redirect() if try catch block . Basically, it adds a redirection header to the response, and it calls Response.End. This is where you get all the trouble from: End is really aborting the thread, which is where you get a "ThreadAbortException."
It's probably this exception you're catching when redirecting. And of course, the second redirect wins... Solution?
Use the non-aborting version of Redirect: Response.Redirect("currentpage.aspx", false);
Solution 2:
Catch the exact exception class not for generalized exception class
Hope this helps ans solves your issue.
Comments
Post a Comment