1

我已经为 asp.net mvc 应用程序实现了注销功能。我有一个名为 SignOut 的按钮,对于按钮单击,我将代码挂接到 Controller 类中,如下所述:

public void SignOut()
                   {
                             try
                             {
                                      WSFederationAuthenticationModule.FederatedSignOut(null, null);                              
                             }
                             finally
                             {
                                      if (FederatedAuthentication.SessionAuthenticationModule != null)
                                                FederatedAuthentication.SessionAuthenticationModule.DeleteSessionTokenCookie();
                             }
                   }

我在该行中遇到错误,FederatedAuthentication.SessionAuthenticationModule.DeleteSessionTokenCookie();如下所述:

错误:发送 HTTP 标头后服务器无法修改 cookie。

任何人都可以帮助我解决上述问题。

4

2 回答 2

0

FederatedSignOut 删除 SessionTokenCookie 然后重定向到方法参数(这是你的情况是空的)。

所以“finally”子句不是必需的。

当您删除它时它会起作用,对吗?

于 2012-02-14T18:24:50.097 回答
0

你的控制器应该返回一个EmptyResult。例如:

[HttpPost]
[Route("logoff", Name = "LogOff")]
[ValidateAntiForgeryToken]
public ActionResult LogOff()
{
    WSFederationAuthenticationModule.FederatedSignOut(new Uri(FederatedAuthentication.WSFederationAuthenticationModule.Issuer), new Uri(FederatedAuthentication.WSFederationAuthenticationModule.Reply));

    return new EmptyResult();
}
于 2017-01-24T22:00:41.420 回答