2 Replies - 218 Views - Last Post: 07 May 2019 - 04:51 AM Rate Topic: -----

#1 SteveHi   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 60
  • Joined: 07-June 15

Why is aspx page not personalised, please?

Posted 01 May 2019 - 08:15 AM

Hello

The vb.net code behind Microsoft's ASP.NET Identity new user aspx.vb file looks like this:

Partial Public Class Register
    Inherits Page
    Protected Sub CreateUser_Click(sender As Object, e As EventArgs)
        Dim userName As String = Email.Text
        Dim manager = Context.GetOwinContext().GetUserManager(Of ApplicationUserManager)()
        Dim signInManager = Context.GetOwinContext().Get(Of ApplicationSignInManager)()
        Dim user = New ApplicationUser() With {.UserName = userName, .Email = userName}
        Dim result = manager.Create(user, Password.Text)
        If result.Succeeded Then
           
           Dim code = manager.GenerateEmailConfirmationToken(user.Id)
           Dim callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id, Request)
           manager.SendEmail(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=""" & callbackUrl & """>here</a>.")

            signInManager.SignIn(user, isPersistent:=False, rememberBrowser:=False)
            IdentityHelper.RedirectToReturnUrl(Request.QueryString("ReturnUrl"), Response)
        Else
            ErrorMessage.Text = result.Errors.FirstOrDefault()
        End If
    End Sub


I wished to redirect the new user to another, personalised page, success_test.aspx after registering, so I commented
out this line from the above code:

 IdentityHelper.RedirectToReturnUrl(Request.QueryString("ReturnUrl"), Response)


and, just below it, inserted

    Dim target = String.Format("~/success_test.aspx?Email={0}", Email.Text)

            Response.Redirect(target, True)

        Else
            ErrorMessage.Text = result.Errors.FirstOrDefault()
        End If
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not IsPostBack Then

            Email.Text = String.Format("{0}", Request.QueryString("Email"))

        End If

    End Sub
End Class


On the line that begins 'Dim target', I am getting a green underline here: 'Email.Text', with the warning 'Variable email is used before it has been assigned a value'. Yet the email input text field has an ID of Email. The page does redirect, but success_test.aspx is not personalised with an email address as it should be.

On success_test.aspx, I have:

<asp:Label ID="Email" runat="server"></asp:Label>  
 , you have successfully registered. Please check your email to log-in.


and in success_test.aspx.vb, I have:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Request("Email") IsNot Nothing Then
           Email.Text = String.Format("{0}, ", Request("Email"))
        End If

       End Sub


Sorry to post so much text, but why is the user's email not displayed, please?

Thank you

This post has been edited by SteveHi: 01 May 2019 - 08:19 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Why is aspx page not personalised, please?

#2 DarenR   User is offline

  • D.I.C Lover

Reputation: 602
  • View blog
  • Posts: 3,993
  • Joined: 12-January 10

Re: Why is aspx page not personalised, please?

Posted 01 May 2019 - 09:28 AM

in your asp.net label try adding text=""

sometimes asp hickups
Was This Post Helpful? 0
  • +
  • -

#3 SteveHi   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 60
  • Joined: 07-June 15

Re: Why is aspx page not personalised, please?

Posted 07 May 2019 - 04:51 AM

Thanks for your reply, Darren

It seems to be working now.

Regards
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1