使用asp.net中刚刚创建的用户帐户将用户登录到站点 [英] logging in the user to the site under the just-created user account in asp.net
本文介绍了使用asp.net中刚刚创建的用户帐户将用户登录到站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经以编程方式创建了一个页面register.aspx,以使用户可以在我的应用程序中进行这样的注册
Hi,
i have created a page register.aspx programmatically to let users register in my application like this
MembershipUser newUser = Membership.CreateUser(TBUserName.Text, TBPassword.Text, TBUserEmail.Text, TBquestion.Text, TBAnswer.Text, true, out createStatus);
我能够创建用户,但是我不知道如何在注册用户时自行登录用户,请Plz帮助.
感谢
i am able to create the user but i don''t know how to log the user in itself when user is registered, Plz help.
Thanks
推荐答案
和往常一样, MSDN [ ^ ]提供了答案:
As usual, MSDN[^] provides the answer:
if (Membership.ValidateUser(TBUserName.Text, TBPassword.Text))
{
if (Request.QueryString["ReturnUrl"] != null)
{
FormsAuthentication.RedirectFromLoginPage(TBUserName.Text, false);
}
else
{
FormsAuthentication.SetAuthCookie(TBUserName.Text, false);
}
}
else
{
Response.Write("Invalid UserID and Password");
}
这篇关于使用asp.net中刚刚创建的用户帐户将用户登录到站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文