ASP.NET无法计算表达式,因为代码已优化或本机框架位于调用堆栈顶部

ASP.NET无法计算表达式,因为代码已优化或本机框架位于调用堆栈顶部,asp.net,Asp.net,我对该代码有问题: HttpContext.Current.Response.Redirect("~/Examples/my.aspx"); //or HttpContext.Current.Response.Redirect("~/Examples/my.aspx",true); 上面的代码生成了我在本主题标题中提到的错误 我只需要刷新我的ASP.NET页面,无法使用该代码: HttpContext.Current.Response.AddHeader("Refresh","2"); 因为

我对该代码有问题:

HttpContext.Current.Response.Redirect("~/Examples/my.aspx");
//or
HttpContext.Current.Response.Redirect("~/Examples/my.aspx",true);
上面的代码生成了我在本主题标题中提到的错误

我只需要刷新我的ASP.NET页面,无法使用该代码:

HttpContext.Current.Response.AddHeader("Refresh","2");
因为它说的是IIS管道模式


问题是我必须进入OnLoad方法,其中刷新/重定向后某些条件为真

是否捕获ThreadAbortException?您可以尝试将代码修改为:

HttpContext.Current.Response.Redirect(“~/Examples/my.aspx”,false)

您可以在以下链接中找到更多有用的信息:


您是否捕获了ThreadAbortException?您可以尝试将代码修改为:

HttpContext.Current.Response.Redirect(“~/Examples/my.aspx”,false)

您可以在以下链接中找到更多有用的信息:


尝试以下代码

strURL=”“~//示例//my.aspx”“

ScriptManager.RegisterStartupScript(此, this.GetType(),“red”, “window.location.href=”+strURL+ “;”,对)


请尝试使用以下代码

strURL=”“~//示例//my.aspx”“

ScriptManager.RegisterStartupScript(此, this.GetType(),“red”, “window.location.href=”+strURL+ “;”,对)


仅在重定向中添加false
它适用于我

仅在重定向中添加false
它适用于我

请按示例展开您的答案,请编辑您的答案以提供适合您的特定代码片段。按示例展开您的答案,请编辑您的答案以提供适合您的特定代码片段。