views:

179

answers:

1

What are all the available routing key words?

I've seen examples using resource, pathInfo, url, controller, action, etc, but I have no clue what is available for me to use.

I know if you just put an arbitrary word like "{blah}" in there, you are defining a parameter that will be used, but I'm guessing you won't be able to use "{resource}" as a parameter name.

+1  A: 

{controller} and {action} are the only two that are reserved in MVC v1. MVC v2 may additionally reserve {area}, but the details on that are still being fleshed out. When I say "reserved", I mean that MVC gives special meaning to them, but from a Routing perspective they're all keywords just the same and are not terribly special.

If you want, you can take controller, action, or any other reserved keyword in as a parameter to your action method. They're treated just like any other parameter.

Levi
@Levi, there appear to be others as well: http://stackoverflow.com/questions/987105 and http://stackoverflow.com/questions/1070710 discuss this.
Dan Atkinson
The question was about reserved keywords in the context of routing parameter names, for which I gave an exhaustive list. Obviously ASP.NET and IIS will impose their own limitations for URLs in general, such as not being able to contain DOS device driver names and certain character escape sequences, but this is independent of Routing or MVC. For example, you can have a route parameter named {com1} if you so desire, and this will work just fine. But if you try to use the literal path segment 'COM1' anywhere in the request URL, ASP.NET will complain.
Levi
In ASP.NET 4, many of those URL limitations imposed by ASP.NET (such as "COM1") will go away. Those are not limitations imposed on routing as Levi said.
Haacked
By the way, Levi is a developer on the ASP.NET MVC team, so he knows what he's talking about. :)
Haacked
Is there a place where any of this is documented? The learning material on the MVC website doesn't mention there are key words. How would I know that "url", "pathInfo", and "resource" are available to use?
Josh Close