Say I have a controller that processes a CRUD script for a "home". Get will look something like this:
[HttpGet] public ActionResult Index(int? homeId) { Home home = homeRepo.GetHome(homeId.Value); return Json(home, JsonRequestBehavior.AllowGet); }
So far so good. Then I add a post-action to add new ones.
[HttpPost] public ActionResult Index(Home home) {
Tall. But when I use the same scheme to handle puts (updating an existing home) ...
[HttpPut] public ActionResult Index(Home home) {
We are facing a problem. The method signatures for Post and Put are identical, which, of course, C # does not like. I could try several things, for example add dummy parameters to the signature or change the names of methods to directly reflect CRUD. However, they are hacks or unwanted.
What is the best practice for keeping RESTful, CRUD style controllers here?
Dusda source share