Is it possible to separate the ID in a URL (Home/Index/10) from a form submit that uses HttpPost and pass them to a controller?
Further explaination
A code example could be:
[HttpPost]
public ActionResult Index(int id, CustomerInfo info)
{
/*
* Code
*/
Return View();
}
CustomerInfo is an object which in this case would contain an int called "ID" and other customer related info.
If I submit a form and want to pass a CustomerInfo ID and a url parameter id both the url id and CustomerInfo.id will be the CustomerInfo id which I passed from the form. If I don't pass a CustomerInfo ID they both will be the url parameter id.
Simply looking at the url id in the controller isn't an option as I need to check if an ID is given in CustomerInfo or not.
I understand that I can just give the CustomerInfo ID another name (eg. CustomerInfoID) but would like to know if I can keep the url parameter id and the CustomerInfo ID the same names.
In the image above you'll see my issue. I did NOT provide an ID for CustomerInfo.ID. It simply passed it to there from the url parameter id when I submit my form. I want the ID of CustomerInfo to be empty when I don't provide one.