Passing a string as an argument to a controller

I know this is probably really obvious, but I can't figure out why I can't pass a string argument to the controller like an int.

eg.

//controller/action/2
public ActionResult Action(int someInt)
{
//somenumber != null
}

      

but when i pass the string this way ...

//controller/Action/x9294kskw
public ActionResult Action(string someString)
{
//someString = null
}

      

What am I missing? I assume it has to do with routing, but ... I have no idea. Thank!

edit:

Maybe I'm reading scott gu's blog a little too casually, but is this documented somewhere? I had to check the routes!

Is there a specific reason why strings are treated differently than ints?

+1


source to share


1 answer


It should be named "id" as the default configuration for the route.



+2


source







All Articles