I have a hidden form field to delete an item in my razor web pages application
<input type="hidden" value="137" name="id">
user can easily alter the item value and delete other user's product, how do we secure this ?
I have a hidden form field to delete an item in my razor web pages application
<input type="hidden" value="137" name="id">
user can easily alter the item value and delete other user's product, how do we secure this ?
You should do server-side validation to ensure that that user has the appropriate authorization to edit/delete (or any other action) that entity.
As an example, in your Controller
[HttpPost]
public ActionResult Delete(int? id)
{
if (CanUserDeleted(id))
{
Delete(id);
// more magic
}
else
{
// Give the user an error
}
}