2013-03-19 50 views
1

當我設置這樣的ASP MVC如何創建自定義FormsAuthentication.SetAuthCookie?

FormsAuthentication.SetAuthCookie(model.UserName, true); 

的AuthCookie的model.userName實際上是用戶的電子郵件這就是唯一識別每個用戶,然後在我看來,當我使用:

Welcome <strong> @User.Identity.Name</strong>! 

它顯示「歡迎use​​[email protected] !,但我想用戶user.firstname。

所以,我的問題是,是否有可能實現自定義User.Identity或自定義Forms.SetAuthCookie,這將允許我使用這樣的東西o我的看法:

Welcome <strong> @User.Identity.FirstName</strong>! 

回答

1

您可以訪問MembershipUser類提供的一些信息。但是,名字或姓氏沒有屬性,這意味着您需要實現自定義成員資格用戶/提供者。請參閱this article

相關問題