1
I tested by taking the id and passing via url, normally performs the operation as long as it exists, otherwise error as expected.
EX:
http://localhost:55199/Person/Delete/7
http://localhost:55199/Person/Edit/7
How can I address this issue? See a form of validation, so that if the id parameter is passed via direct url does not work or something like that, otherwise anyone can pass any id and delete important data or edit.
[HttpPost]
public ActionResult Edit(Pessoa model)
{
if (ModelState.IsValid)
{
Pessoa p = new Pessoa();
p.Salvar(model);
return View("List", p.Listar());
}
else
return View("Create", model);
}
public ActionResult Delete(int id)
{
Pessoa p = new Pessoa();
p.Deletar(id);
return View("List", p.Listar());
}
It is not by changing the URL that you will increase the security of the application. You do not have any user management system?
– Woss
At the moment still, I’m studying a way to create yet.
– JB_
This you want, is achieved through Authentication and Authorization, because the validation you need is whether the user is logged in to the system, and whether it is allowed to perform certain action. Other than that, you shouldn’t do delete operations via GET as mentioned in the @Thiagopires reply.
– L. Albano