justSteve
justSteve

Reputation: 5524

Can the MVC's parameter list be dynamic?

If:

http://mySite/Users/9055 

returns a db record where UserID=9055 (via the userController.getUserID method)

And:

http://mySite/Users/Smith 

returns the same record via the userController.getUserName method

Isn't it reasonable to code a controller method that parses the either input?

Seems like a great option to users - the url as a means of navigating - as long as the top-level (controller) is broad yet focused enough (Users, Products, Billing, Reports) how do we parse for (so we can search on) any of several different datatypes?

thx

Upvotes: 0

Views: 163

Answers (1)

Andrey
Andrey

Reputation: 60075

you can have a string parameter for controller's action and then do int.TryParse to check if it is integer. if not assume that it is string

Upvotes: 4

Related Questions