开发者

CreateUserWizard: After registering, I'd like the user to be automatically logged on

开发者 https://www.devze.com 2023-01-05 23:49 出处:网络
I am using the CreateUserWizard to register a user. The control\'s built-in logic is doing all the work to add the user. However upon registering, I would like the user to be considered \"authenticate

I am using the CreateUserWizard to register a user. The control's built-in logic is doing all the work to add the user. However upon registering, I would like the user to be considered "authenticated." I thought that the Authenticate function would have authenticated me, but the function sets the Authenticated Boolean to False. Note however that the ValidateUser function returns True.

How do I automat开发者_如何学Goically sign on/authenticate the use after registering so he doesn't have to "log on" after just registering with his new credentials?

Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, 
              ByVal e As System.EventArgs) Handles CreateUserWizard1.CreatedUser

  Dim Authenticated As Boolean =
                     FormsAuthentication.Authenticate(CreateUserWizard1.UserName,
                                                      CreateUserWizard1.Password)
  Dim Validated As Boolean = Membership.ValidateUser(CreateUserWizard1.UserName,
                                                     CreateUserWizard1.Password) 
End Sub


If the validated does indeed turn out to be correct then you can use SetAuthCookie.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号