I'm not getting what's going on:
In my HomeController I have a:
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
[HttpGet]
public IActionResult Post()
{
return View(new Post());
}
[HttpPost]
public IActionResult Edit(Post post)
{
return View();
}
}
If I run my app and go to localhost8888/Home/Edit I get a 405 error with `
This Page is not working
However if I change EDIT method to [HttpGet] or remove the action all together the Edit razor view loads successfully.
Razor View:
@model Post
<div>
<form asp-controller="Home" asp-action="Edit" method="post">
<div>
<label>Title</label>
<input asp-for="@Model.Title"/>
<label>Body</label>
<input asp-for="@Model.Body" />
</div>
<input type="submit" value="Submit"/>
</form>
</div>
Why is that happening?