我有多个MVC3站点,可以创建FormsAuthentication票证并将它们存储在cookies中。
登录:
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名称有什么害处吗?还是有另一种推荐的方法呢?
发布于 2012-08-27 09:00:29
只有当这些多个站点位于同一个域时,它才会引起问题。
您可以在web.config中设置cookie名称-请参阅Can I change the FormsAuthentication cookie name?
https://stackoverflow.com/questions/12138930
复制相似问题