MVC 5 Identity issue: Tried change the registration form to user a user name. The default is sets to email But i need real user names I get error when I change to UserName. I made 2 changes

I get the error message below, when I try to register a user on my MVC5 website.  I need the registration to user a real user name not the email. The default setting is set to user email for user name out of the box.  I made two changes that i thought should work.  

1st, In the Register Post Action on the AccountController set it to UserName rather than Email

 2ed,  I changed the following code and add UserName to the RegisterViewModel
<div class="form-group">
        @Html.LabelFor(m => m.UserName, new { @class = "col-md-2 control-label" })
        <div class="col-md-10">
            @Html.TextBoxFor(m => m.UserName, new { @class = "form-control", @placeholder = "Username or email" })
        </div>

Open in new window



Again this is so it will not use the email as the UserName when visiters register.

Now this is the Error message I get:
'MVCMemberApp.Models.RegisterViewModel' does not contain a definition for 'UserName' and no extension method 'UserName' accepting a first argument of type 'MVCMemberApp.Models.RegisterViewModel' could be found (are you missing a using directive or an assembly reference?)

Open in new window


Note: the code worked with email

Thanks for any help!
bmanmike39Asked:
Who is Participating?
 
Ronak PatelCommented:
Hi bmanmike39,

From the error message, it seems like the "UserName" property is missing in your RegisterViewModel's model definition.

You need to add the "UserName" property to your model in order to use it on the View.


Hope this helps.

Regards,
Ronak
0
 
bmanmike39Author Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.