views:

50

answers:

2

From Rails and some people's ASP.NET MVC examples I got the feeling that routes are mostly written in lowercase. C# conventions do require uppercase classes and method names so controllers and controller action's will remain uppercase but I'm wondering if I should start writing routes in global.asax.cs in all lowercase (as opposed to what I do now, which is uppercase).

This

routes.MapRoute("GetPosts", "PostCode/GetPosts", new { controller = "PostCode", action = "GetPosts" });

or this

routes.MapRoute("getposts", "postCode/getposts", new { controller = "PostCode", action = "GetPosts" });

or this

routes.MapRoute("posts", "postcode/posts", new { controller = "PostCode", action = "GetPosts" });

or something else?

+2  A: 

I prefer camel case for the route name and url pattern the way it is in your first example.

You can also create a static file of public constants to store route names if you need to use them in other places. Then you can reference MyRouteNames.Posts and MyRouteNames.GetPosts to encapsulate the strings.

Joe Wilson
A: 

It's really up to you and which way you prefer. I prefer to use upper case since that is what I am used to doing, but I don't think there is any right/wrong way in this case.

amurra