Extending Registration

I have added some values to RegisterApplicationUser.razor (first name, last name, locationId drop-down) and this has gone well with Radzen. I intend to persist these fields to a separate table that will have FK to AspNetUsers.Id.

When I add the parameters to AccountController.Register() for firstName and lastName, they magically get passed in. This may be because I added the three properties to ApplicationUser as NotMapped. However, have not been able to get the value of the locationId drop-down into Register():

    public async Task<IActionResult> Register(string userName, string email, string password, string firstName, string lastName, int locationId)

What is the mechanism that passes values to Register()? There is something small which I need to tell it so that the location drop-down value comes through. :slight_smile:

With all this said, something smells wrong about editing generated code, and I should instead be doing something to generate the desired code. So a different/broader question might be "is it possible to add 3 custom fields to the asp.net identity in some way such that one can be FK to an application table"? My parallel/1:1 table approach is very close, I'm only lacking the locationId value.

The Form component in the Register page posts to the Register action of the AccountController class. This is why parameters get posted. If something is missing check your browser's HTTP requests to see what gets posted.

In a future release we will introduce a partial method which will allow you to set properties of the ApplicationUser or do anything else during registration. For now editing the generated code should suffice.

Excellent suggestion, I feel stupid now. :stuck_out_tongue_closed_eyes:

You were right, the LocationID dropdown that I've added is not being passed along. I've been chipping away at it, but still can't determine why. This is the added code:

        <div style="margin-bottom: 1rem" class="row">
          <div class="col-md-3">
            <RadzenLabel @ref="label0" @ref:suppressField Component="LocationID" style="width: 100%" Text="Location">
          <div class="col-md-9">
            <RadzenDropDown @ref="locationId" @ref:suppressField Data="@(getLocationsResult)" style="width: 100%" TextProperty="LocationName" ValueProperty="LocationID" Name="LocationID">
            <RadzenRequiredValidator @ref="locationRequiredValidator" @ref:suppressField Component="LocationID" style="position: absolute" Text="Location is required">

I simply copy an existing row, and then change as needed. In this case I removed the TextBox and replaced it with a DropDown, and changed some names. The body of the POST to /account/register receives all the other controls (even new ones). I just can't get this one to squeeze through. Makes me wonder if it's even looking for drop-downs here.

Reproduced. The DropDown component isn't getting posted at the moment. We will address that.

We have addressed this issue with Radzen.Blazor 0.71 (included in Radzen 2.21.0).

This fix is working very nicely for me.