How action parameters are identifies in ASP.NET MVC?

0 votes
asked Jun 26, 2013 in ASP.Net MVC by anonymous

How the ASP.NET MVC framework does find parameters of an action? Does it identify only from URL or it also looks somewhere else? What is the concept behind these action parameters?


1 Answer

+1 vote
answered Jun 26, 2013 by Aadhira (1,213 points)
selected Jun 30, 2013 by administrator
Best answer

In ASP.NET MVC Framework, the MVCHandler will invoke the controller and call the action, based on the routing information. When the action invoker, invokes the method, it will see whether the action is expecting any parameter. If so, it will look at the following places to find the matching parameter value and pass it to the method.

If the parameter is primitive type, then the MVC Action Invoker
Look for the parameter inside Route Data that comes with the http request.
If not, it will try to find it from Form Data
If not; it may try inside the Query String that comes with the URL request.
If in none of the places it finds parameter, then action invoker will pass null value. (If our parameter accepts null value, then we are ok)

If the parameter is non primitive type (Complex Type), then the Model Binder will get the form data and bind the value with the complex object. Here the restriction is, the properties in the Model binder must be public properties and match with the name in the form, if you use the default model binder that comes with MVC Framework. Otherwise, you can implement your own binder.

Your answer


Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
site design / logo / content © 2013 - 2015