Reputation: 4266
I'm making a basic app in MVC.
I have a edit page. That page is feed by the object ID.
public ActionResult Edit(int id)
When you see this edit page, a "Save" button is in the bottom.
<input type="submit" value="Save" />
So I made a second method that is called to perform changes in DB :
public void Edit(MyObject object)
I have troubles because they all have the same method name.
So how Can I rename the second method name (that receive the custom object)? The button must be linked again to the method that perform edition in DB...
Thanks !
Upvotes: 2
Views: 81
Reputation: 4212
Try with it
[HttpPost]
public void Edit(MyObject object)
or
[HttpPost]
[ActionName("MyOverloadedName")]
public void Edit(MyObject object)
Upvotes: 2
Reputation: 887453
There is nothing wrong with two actions that have the same name.
However, you should add [HttpPost]
to the POST action.
Upvotes: 2