Sachin Kainth
Sachin Kainth

Reputation: 46740

MVC3 Parameters in Controller Methods Convention

Quite often when writing controllers you need to use a parameter name other than the default of "id". In this case, the lazy coder in me wants to use the old fashioned convention of using parameter1=abc but then there is a little voice in my head that says I should set up custom routes. The question is which approach is better?

Thanks,

Sachin

Upvotes: 0

Views: 170

Answers (1)

lalibi
lalibi

Reputation: 3078

You can do this already with the default routes but in the first case the url will be

website/controller/action/1

while on the other case the url will be

webite/controller/action?param=abc

Does this fit your needs?

The problem is that id and param cannot be of the same type. You can't declare the same action twice with the same signature.

Upvotes: 1

Related Questions