C# 正在将配置文件图片上载到ASP.NET标识

C# 正在将配置文件图片上载到ASP.NET标识,c#,asp.net,C#,Asp.net,我正在尝试将图像添加到我的用户模型中 namespace GoldTeamProject7.Models { public class ApplicationUser : IdentityUser { public string FirstName { get; set; } public string LastName { get; set; } public string Zipcode { get; set; }

我正在尝试将图像添加到我的用户模型中

namespace GoldTeamProject7.Models
{
    public class ApplicationUser : IdentityUser
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Zipcode { get; set; }
        public byte[] ProfileImage { get; set; }
....
}
我想能够上传注册时的照片

 public async Task<ActionResult> Register(RegisterViewModel model, HttpPostedFileBase ImageFile)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { UserName = model.Email, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, Zipcode = model.Zipcode, ProfileImage = model.ProfileImage };
                var result = await UserManager.CreateAsync(user, model.Password);

                using (var ms = new MemoryStream())
                {
                    ImageFile.InputStream.CopyTo(ms);
                    ApplicationUser.ProfileImage = ms.ToArray();
                }
我得到一个错误,上面写着

“错误24非静态字段需要对象引用, 方法或属性 'GoldTeamProject7.Models.ApplicationUser.ProfileImage.get'C:\Users\sethj\u 000\documents\visual 演播室 2013\Projects\GoldTeamProject7\GoldTeamProject7\Controllers\AccountController.cs 161 21 GoldTeamProject7“


我将属性添加到模型中,将属性添加到视图模型中,添加代码将其写入控制器中的Db中,但我似乎无法理解为什么会得到该对象错误引用。有人能帮我吗

它应该是
user.ProfileImage=ms.ToArray()
和put
var result=await UserManager.CreateAsync(user,model.Password)下面的行
使用
谢谢,就这样!我需要将该数据添加到ApplicationUser类创建的对象中。我现在明白了。多谢各位
<div class="editor-label">
    @Html.LabelFor(m => m.ProfileImage)
</div>

<input name="Image" type="file" />
<p>
    <input name="ImageFile" type="file" />
</p>
 ApplicationUser.ProfileImage = ms.ToArray();