I am working with ASP.Net MVC 4 and entity framework. I have a table for inserting and updating reviews against restaurant by it's customer. While updating customer can't change their name. they can change only only change Rating and Comment. So, I have delete the input code for reviewerName(Customername) FROM MY VIEW PAGE OF THE mvc. But hacker can change the name or reviews_id by "Mass Assignment" / "Over posting". Means they can send ReviewerName by posting it in url as query string.
~/Reviews/Edit?ReviewerName=Hacker
To prevent it I have use Bind model binding with exclude parameter. Yes it prevent hacker to inject ReviewerName. But also deleting reviewer name from database table. Is there any way to solve this rather using "include".My controller code is below.
public ActionResult Edit([Bind(Exclude = "ReviewerName")] RestaurantReview review)
{
if (ModelState.IsValid)
{
_db.Entry(review).State = System.Data.EntityState.Modified;
_db.SaveChanges();
return RedirectToAction("Index", new { id = review.RestaurantId });
}
return View(review);
}