Search code examples
asp.net-identityaspnetboilerplate

How can i add custom field in user registration asp.net boilerplate


I am using aspnet boilerplate template. In that inbuilt registration consist for some default fields only. How can i add new custom fields, so that when user registers they want to enter that also?

public class User : AbpUser<User>

if i create a attribute in this class it will work?


Solution

  • Follow these steps:

    For .NET Core 2.0 + Angular

    1. Create a property in User.
    2. Add the property in RegisterInput.
    3. Add the form field in register.component.html.
    4. Bind the property in AccountAppService's Register method:

      user.MyProperty = input.MyProperty;
      

    For .NET Core 2.0 + MVC

    1. Create a property in User.
    2. Add the property in RegisterViewModel.
    3. Add the form field in Register.cshtml.
    4. Bind the property in AccountController's Register method:

      user.MyProperty = model.MyProperty;