mvc4在电子邮件确认期间自动登录用户

时间:2013-07-25 08:46:43

标签: c# asp.net-mvc simplemembership

当用户在我的网站上注册时,我发送了一封带有确认信息的电子邮件(来自webpages_Membership表)。

当用户点击链接时,我确认帐户:

 WebSecurity.ConfirmAccount(guid);

我现在想在这篇帖子中记录用户:Is it a bad idea to automatically log users in from an email?

我该怎么做?

1 个答案:

答案 0 :(得分:1)

如果您使用的是标准会员制,则应致电

FormsAuthentication.SetAuthCookie("username", true);

http://msdn.microsoft.com/en-us/library/twk5762b.aspx