'ASP.NET webforms VB using username instead of email as username

I don't want use email as username, I amended the code to add first name and last name but cant get it to use usernames, it keeps going to email in aspnetusers table

I'd like the users to navigate to other users using their username and keeping emails confidential

Protected Sub Unnamed4_Click(sender As Object, e As EventArgs)
        If Me.Password.Text = Me.ConfirmPassword.Text Then
            Dim userName As String = signinSrEmail.Text
            Dim manager = Context.GetOwinContext().GetUserManager(Of ApplicationUserManager)()
            Dim signInManager = Context.GetOwinContext().Get(Of ApplicationSignInManager)()
            Dim user = New ApplicationUser() With {.UserName = userName, .Email = userName, .FirstName = TextBoxFname.Text, .Surname = TextBoxSName.Text}
            Dim result = manager.Create(user, Password.Text.ToString)
            If result.Succeeded Then
                'For more information on how To enable account confirmation And password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                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>.")
                If user.EmailConfirmed Then
                    'Response.Cookies("UserName").Expires = DateTime.Now.AddDays(30)
                    FormsAuthentication.SetAuthCookie(user.Id, False)
                    signInManager.SignIn(user, isPersistent:=False, rememberBrowser:=True)
                    IdentityHelper.RedirectToReturnUrl(Request.QueryString("ReturnUrl"), Response)
                Else
                    ErrorMessage.Text = "An email has been sent to your account. Please view the email and confirm your account to complete the registration process."
                End If

            Else
                    errormessage.Text = result.Errors.FirstOrDefault()
            End If

        Else
            errormessage.Text = "Passwords do not match"
        End If
    End Sub
End Class


Solution 1:[1]

You are storing Email Id in userName. if you don't want to use email as user name then you have to use this

 Dim userName As String = TextBoxFname.Text +"   "+.Surname = TextBoxSName.Text

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 M Rizwan