views:

84

answers:

1

I know this is probably really obvious, but I cannot figure out why I cannot pass a string argument to a controller like one would an int.

e.g.

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

but when i pass a string in like this...

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

What am I missing? I'm guessing this has to do with routing but...I have no idea. Thanks!

edit:

Maybe I read over scott gu's blog a little too carelessly, but is this documented somewhere? I should have checked the routes!

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

+2  A: 

It need to have the name 'id', as setup in the route's default config.

leppie
To clarify: it doesn't *have* to have the name "id" - it simply has to have the *same* name as defined in the route.
Marc Gravell