Click here to Skip to main content
15,947,785 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I working on core 5 mvc web application , I face issue I can't store Picture User on database table [dbo].[AspNetUsers].

so can you tell me how to store personal picture of user on table [dbo].[AspNetUsers].

I already add new column PictureUser on table [dbo].[AspNetUsers] to store User Picture .

I need to know what I will modify on controller and view to store user picture on database table .

I working on Microsoft identity membership when register user

How to add Image Upload on View And Controller Action this is Exactly my Question ?

What I have tried:

my model as

public class RegisterVM
    public string EmailAddress { get; set; }
    public string Password { get; set; }
    public byte[] PictureUser { get; set; }

my action controller

    public async Task<IActionResult> Register(RegisterVM registerVM)
        var newUser = new ApplicationUser()
            FullName = registerVM.FullName,
            Email = registerVM.EmailAddress,
            UserName = registerVM.EmailAddress,
            //How to add Image upload Here
        var newUserResponse = await _userManager.CreateAsync(newUser, registerVM.Password);
        if (newUserResponse.Succeeded)
            await _signInManager.SignInAsync(newUser, isPersistent: false);
            return View("RegisterCompleted");
        return View(registerVM); 
on view

@model RegisterVM;

                <form asp-action="Register">
                    <div asp-validation-summary="ModelOnly" class="text-danger"></div>

                    <div class="form-group">
                        <label asp-for="EmailAddress" class="control-label"></label>
                        <input asp-for="EmailAddress" class="form-control" />
                        <span asp-validation-for="EmailAddress" class="text-danger"></span>
                    <div class="form-group">
                        <label asp-for="Password" class="control-label"></label>
                        <input asp-for="Password" class="form-control" />
                        <span asp-validation-for="Password" class="text-danger"></span>
                     //How to add Image upload Here

                    <div class="form-group">
                        <input class="btn btn-outline-success float-right" type="submit" value="Sign up" />
Updated 4-Dec-22 23:34pm

1 solution

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900