This is a controller action that I invoke using the post ajax method:
[HttpPost] public ActionResult Add(Comment comment) { if (User.Identity.IsAuthenticated) { comment.Username = User.Identity.Name; comment.Email = Membership.GetUser().Email; } if (ModelState.IsValid) { this.db.Add(comment); return PartialView("Comment", comment); } else {
If the user is logged in, there are no user name and email fields in the send form, so they are not transmitted when ajax is called. When the action is called ModelStat.IsValid returns false because these two properties are necessary. After I set valid values ββfor the properties, how do I initiate a model check to update the ModelState?
c # asp.net-mvc
frennky
source share