I have the following snippet of code which registers a user and adds the record to the database and works fine. You will see it redirects to a page which is in a secured directory. How can I auto login the user after they have registered so that they can access the page.
Code:
If rbHomeBody.Checked = True Then
Me.hdnMembershipType.Value = "3"
'Add record here
Dim ConnString As [String] = ConfigurationManager.ConnectionStrings("quickbabysitConnectionString").ConnectionString
Dim con As New SqlConnection(ConnString)
Dim cmd As New SqlCommand()
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "AddNewParentRegistration"
cmd.Parameters.Add("@Firstname", SqlDbType.VarChar).Value = txtFirstname.Text.Trim()
cmd.Parameters.Add("@Surname", SqlDbType.VarChar).Value = txtSurname.Text.Trim()
cmd.Parameters.Add("@EmailAddress", SqlDbType.NVarChar).Value = txtEmail.Text.Trim()
cmd.Parameters.Add("@Password", SqlDbType.NChar).Value = txtPassword.Text.Trim()
cmd.Parameters.Add("@AddressLine1", SqlDbType.VarChar).Value = txtAddress1.Text.Trim()
cmd.Parameters.Add("@AddressLine2", SqlDbType.VarChar).Value = txtAddress2.Text.Trim()
cmd.Parameters.Add("@AddressLine3", SqlDbType.VarChar).Value = txtAddress3.Text.Trim()
cmd.Parameters.Add("@AddressLine4", SqlDbType.VarChar).Value = txtAddress4.Text.Trim()
cmd.Parameters.Add("@Town", SqlDbType.VarChar).Value = txtCity.Text.Trim()
cmd.Parameters.Add("@Postcode", SqlDbType.VarChar).Value = txtPostcode.Text.Trim()
cmd.Parameters.Add("@ContactPhone", SqlDbType.VarChar).Value = txtPhone.Text.Trim()
cmd.Parameters.Add("@NumberKids", SqlDbType.Decimal).Value = ddlKids.SelectedValue.Trim()
cmd.Parameters.Add("@MembershipType", SqlDbType.Int).Value = hdnMembershipType.Value.Trim()
Dim ParentID As New SqlParameter("@ParentID", SqlDbType.Int)
ParentID.Direction = ParameterDirection.Output
cmd.Parameters.Add(ParentID)
cmd.Connection = con
Try
con.Open()
cmd.ExecuteScalar()
Catch ex As Exception
Throw ex
Finally
con.Close()
con.Dispose()
End Try
' send_email()
pnlRegParent.Visible = False
pnlSuccess.Visible = True
Response.AddHeader("Refresh", "4;URL=parents/booking.aspx")
End If
End If
End If
Else
Me.lblTermsValidation.Visible = True
End If
End Sub