0
我实现的形式授权的自定义Cookie在我的网站:C#静态辅助类 - 访问饼干
http://msdn.microsoft.com/en-us/library/system.web.security.formsauthenticationticket.aspx
因为我存储一些额外的信息用户数据:
Account account = accountRepository.GetAccount(model.Email);
string userData = string.Format("{0}|{1}", account.UserId, account.AccountTypeId);
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
model.Email,
DateTime.Now,
DateTime.Now.AddMinutes(48),
model.RememberMe,
userData,
FormsAuthentication.FormsCookiePath);
我我正在考虑创建一个Static Helper Class来从我的cookie中提取userData。
但是我无法访问我的控制器外部的User.Identity.Name。
我怎样才能访问它oustide我的控制器?做一个静态类是不对的?
感谢
你不使用'用户.Identity.Name'在你的代码中,所以目前还不清楚问题是什么。无论如何,你能传递你需要的任何数据吗? – bmm6o
我已经有了一个解决方案,所以我会发布它。感谢回复。 –