Monday, August 2, 2010

Response.redirect is giving error

If you are getting following error after Response.Redirect()
“Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack”
I have three solutions for this
1) You can use Response.Redirect(“xyz.aspx”,false);

Response.Redirect(String URL,EndResponse);

String URL : Name/URL of your page on which you want to transfer the execution
EndResponse :
if false it will not stop execution immediately but it will allowed page to complete it’s execution and then redirect it to specified your page

if true then it will stop execution and it might give you error.

If you don’t want to execute page and stop and want redirect immediately,
Use second solution.



You can put Response.Redirect() out side of you try catch block


Or Third Solution

Replace Response.Redirect() with folloing code.




No comments:

Post a Comment