Changing MVC router id from integer to string in vb.net

I am browsing some pages and I noticed that the default ID in routing for controller / action / ID is an integer, not a string.

How can I change it to be a string?

+1


source to share


1 answer


Cleanly by creating an action like this:

Public Function MyAction(ByVal id as String) as ActionResult

      



The structure will convert the URL MyController/MyAction/SomeId

for you. It will usually convert the last section to an integer, since this is how your method is defined and you have nothing to prevent you from saying it is a string, so no conversion is required.

+3


source







All Articles