【问题标题】:MVC3 FormsAuthenticationTicket Cookie nameMVC3 FormsAuthenticationTicket Cookie 名称
【发布时间】:2012-08-21 18:15:51
【问题描述】:

可能的重复: Can I change the FormsAuthentication cookie name?

我有多个 MVC3 站点,它们创建 FormsAuthentication 票证并将它们存储在 cookie 中。

登录:

FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, userName, DateTime.Now, DateTime.Now.AddMinutes(15), true, String.Empty);
string encTicket = FormsAuthentication.Encrypt(ticket);
HttpCookie faCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);

在 Application_AuthenticateRequest 中:

HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; 

如果多个站点保存到同一个cookie,这肯定会导致问题吗? 为每个应用设置不同的 cookie 名称有什么害处吗?或者有其他推荐的方法吗?

【问题讨论】:

标签: asp.net-mvc-3 authentication forms-authentication


【解决方案1】:

只有当多个站点在同一个域上时才会导致问题。

您可以在 web.config 中设置 cookie 名称 - 请参阅 Can I change the FormsAuthentication cookie name?

【讨论】:

    猜你喜欢
    • 2010-12-21
    • 1970-01-01
    • 1970-01-01
    • 2011-08-04
    • 1970-01-01
    • 1970-01-01
    • 2012-05-22
    • 2010-10-26
    • 2012-05-30
    相关资源
    最近更新 更多