I do this:
http://localhost:53072/Employee/Delete/2
Thats my action:
[HttpPost]
public ActionResult Delete(int id)
Assuming you are accessing the url via a browser it will make a GET
request and your action is a POST
.
You could either change your request using a tool like fiddler or change your method to this instead:
[HttpGet]
public ActionResult Delete(int id)
{
_provider.Delete(id);
return View();
}
You could also omit the [HttpGet]
as it is the default.
Update
In order to make this a post instead of using an ActionLink you could do the following:
Add this to your view, wrapping it in a begin form
@using(Html.BeginForm("Delete", "Controller", FormMethod.Post))
{
@Html.HiddenFor(m => m.Id)
}
Leave your action as follows:
[HttpPost]
public ActionResult Delete(int id)
{
_provider.Delete(id);
return View();
}