Updating my model then re-evaluate IsValid?

If the missing Values are required for your model but will not be provided until after binding you may need to clear the errors caused by those two values from the ModelState.

[HttpPost, Authorize]
public ActionResult Thread(int id, string groupSlug, Comment comment, string submitButton)
{
  comment.UserID = UserService.UID;
  comment.IP = Request.UserHostAddress;

  //add these two lines
  ModelState["comment.UserID"].Errors.Clear();
  ModelState["comment.IP"].Errors.Clear();

  UpdateModel(comment); //throws invalidoperationexception
  if (ModelState.IsValid) // returns false if i skip last line
  {
    //save and stuff
    //redirect
  }
  //return view
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)