I have a textbox called pass in my Create view
<div class="form-group">
@Html.LabelFor(model => model.Password, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Password, new { htmlAttributes = new { @class = "form-control" } })
</div>
In my AccountController, I tried to validate the password between 8 to 250 letters, the code doesnt seem to work properly as when I tried to run the website, it return error: 'Cannot perform runtime binding on a null reference'
if (ModelState.IsValid)
{
db.Accounts.Add(account);
if(ViewBag.Password.Length > 8 && ViewBag.Password != null)
{
db.SaveChanges();
return RedirectToAction("Index");
}
else return RedirectToAction("Create");