Saturday, March 31, 2012

Strange behavior with activate user in windows 2003 server

Hi,

I code an activate user process who works very great on my computer but when i put it on my server (win server 2003 / SQL server 2005) it doesn't validate (isapproved=true) the user.

Activate.aspx.vb :

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim UserNameEmail As String = Request.QueryString("useremail")
Dim Username As String = Membership.GetUserNameByEmail(UserNameEmail)

If Not String.IsNullOrEmpty(UserNameEmail) Then
Dim usr As MembershipUser = Membership.GetUser(Username)
If Not Nothing Is usr Then
usr.IsApproved = True
Membership.UpdateUser(usr)
Response.Redirect("activate_success.aspx")
Else
Response.Redirect("activate_error.aspx")
End If
Else
Response.Redirect("activate_error.aspx")
End If
Else
Response.Redirect("activate_error.aspx")
End If
End Sub


I don't know why? Someone have an idea please?

Hi,

I need to mention that if i use the UserID for the activation it works:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim UserName As String = Request.Params("USERID")
Dim providerUserKey As Guid = New Guid(UserName)

If Not String.IsNullOrEmpty(UserName) Then
Dim usr As MembershipUser = Membership.GetUser(providerUserKey)
If Not Nothing Is usr Then
usr.IsApproved = True
Membership.UpdateUser(usr)
Response.Redirect("activate_success.aspx")
Else
Response.Redirect("activate_error.aspx")
End If
Else
Response.Redirect("activate_error.aspx")
End If
Else
Response.Redirect("activate_error.aspx")
End If
End Sub

But i want to activate the user with passing only his email and not his UserID because USerID is too confidential...


Ok i understand why it is not working...

Many users can have the same email so the database doesn't know which user to pick...

I will think of that...

0 comments:

Post a Comment