I created an ASP.NET MVC4 project with authentication. When I run my app I get an error:
System.NullReferenceException
on the 17th line in file Views/Accounts/Register. How can I resolve it?
@model ImArtistApp.Models.RegisterViewModel
@{
ViewBag.Title = "Регистрация";
}
<h2>@ViewBag.Title.</h2>
@using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<h4>Создание новой учетной записи.</h4>
<hr />
@Html.ValidationSummary("", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
// Error here
@Html.DisplayFor(m => m.Email, new { @class = "form-control" })
</div> ....
Code of model:
public class RegisterViewModel
{
[Required]
[EmailAddress]
[DataType(DataType.Text)]
[Display(Name = "Адрес электронной почты")]
[UIHint("String")]
public string Email { get; set; }
[Required]
[StringLength(100, ErrorMessage = "Значение {0} должно содержать не менее {2} символов.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Пароль")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Подтверждение пароля")]
[Compare("Password", ErrorMessage = "Пароль и его подтверждение не совпадают.")]
public string ConfirmPassword { get; set; }
}