I am relatively new to MVC3 and had a question about a parameter in a controller.
I have a controller that takes an id
public ActionResult ChooseItem(string id) ...
This controller’s view creates a form, and when the user submits the form it posts to this controller
[HttpPost]
public ActionResult ChooseApp(string id, string itemID)...
The strange thing is, even though I do not have a hidden variable that stores id in the view that is POSTing to this control, the id parameter is set correctly. This is actually a good thing, but I don’t understand where the value is coming from. I have examined the POST values in Chrome dev tools and there is not an id in the form values that are POSTed. What is setting the id value correctly?
If you have an id value in your querystring or your route is defined and it can locate an id element in the URL it will use them. This link describes how default binder works and the priority given to where values come from http://www.howmvcworks.net/OnModelsAndViewModels/TheBeautyThatIsTheModelBinder