【问题标题】:Got error after logout from master page从母版页注销后出现错误
【发布时间】:2012-12-24 12:50:18
【问题描述】:

我在 asp.net 2005 中创建了角色身份验证示例。我在我的 default.aspx 页面上创建了登录面板,登录后它工作正常。我使用如下代码登录

FormsAuthentication.RedirectFromLoginPage(txtUName.Text, true, urlpath);
FormsAuthentication.SetAuthCookie(txtUName.Text, true);
Response.Redirect(urlpath, false);

我在登录后显示的单个母版页中使用了所有必需的页面链接。 我使用母版页中的代码进行“注销”,如下所示点击链接按钮

 try
 {
      Response.Redirect("~/Logout.aspx" );
 }
 catch (Exception ee)
 { 
      return;
 }

现在,当我从母版页注销时,出现这样的错误

unable to evaluate expression because the code is optimized or native frame is on top of call stack

我已经护目镜,但没有得到解决方案。我无法找出这背后的原因。 请提供适当的解决方案。 谢谢

【问题讨论】:

标签: asp.net authentication response.redirect


【解决方案1】:
http://support.microsoft.com/kb/312629/en-us

要解决此问题,请使用以下方法之一: • 对于 Response.End,调用 HttpContext.Current.ApplicationInstance.CompleteRequest 方法而不是 Response.End 以绕过代码执行到 Application_EndRequest 事件。

•对于 Response.Redirect,使用重载 Response.Redirect(String url, bool endResponse) 为 endResponse 参数传递 false 以抑制对 Response.End 的内部调用。例如: Response.Redirect("nextpage.aspx", false);

如果您使用此解决方法,则会执行 Response.Redirect 之后的代码。 • 对于 Server.Transfer,请改用 Server.Execute 方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-22
    • 1970-01-01
    • 2015-08-09
    相关资源
    最近更新 更多