ASP.NET Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack
I have problem with that code:
HttpContext.Current.Response.Redirect("~/Examples/my.aspx");
//or
HttpContext.Current.Response.Redirect("~/Examples/my.aspx",true);
the code above generates the error as I mentioned at this topic开发者_Go百科's title.
I simply need to refresh my ASP.NET page, I can't use that code instead:
HttpContext.Current.Response.AddHeader("Refresh","2");
because it says about IIS pipeline mode
The puprose is that I must get into OnLoad method where some conditions are true after refresh/redirect
Try with the Following Code
strURL = ""~//Examples//my.aspx"";
ScriptManager.RegisterStartupScript(this, this.GetType(), "red", "window.location.href='" + strURL + "';", true);
Are you capturing the ThreadAbortException? You can try modifying your code to read:
HttpContext.Current.Response.Redirect("~/Examples/my.aspx",false);
You might find more helpful information at the following link:
http://support.microsoft.com/kb/312629/EN-US/
add false in redirect only it works with me
精彩评论