我正在使用 Umbraco 8 中的成员 API,我正在尝试在注册时上传图像。在我注册会员并在后台打开会员资料后,我看到了这个:
这是我的控制器
public class RegisterController : SurfaceController
{
// GET: Register
public ActionResult Register(Models.RegisterModel model)
{
if (!ModelState.IsValid)
return CurrentUmbracoPage();
var memberService = Services.MemberService;
if (memberService.GetByEmail(model.Email) != null)
{
ModelState.AddModelError("", "A member with that email alredy exists");
return CurrentUmbracoPage();
}
var member = memberService.CreateMemberWithIdentity(model.Email, model.Email, model.Name, "bMEMembers");
member.SetValue("companyName", model.CompanyName );
member.SetValue("avatar", model.Avatar);
memberService.SavePassword(member, model.Password);
Members.Login(model.Email, model.Password);
memberService.Save(member);
return Redirect("/");
}
}
模型:
public HttpPostedFileBase Avatar { get; set; }
看法:
@Html.LabelFor(model => model.Avatar)
<input type="file" name="Avatar" />
@Html.ValidationMessageFor(model => model.Avatar)
<input class="btn" type="submit" value="Create" />
有人可以帮我解决这个问题吗?