route file extension

Imported from the CodePlex archive for reference purposes. Support for MvcCodeRouting has ended.

Commented on

Hi there.  First off, this library is GREAT.  I come from Castle Monorail, where their concept of Areas allowed something just like this.

I have the need, however, to add a file extension to the routes.  A simple example would be "{controller}/{action}.mvc/{id}" or "{controller}.mvc/{action}/{id}".  The current library does not seem to allow for this.  Would it be possible for a property for this to be added to CodeRouteSettings?  What do you think?

Thanks!

-tyler burd

Commented on link

Can you tell me more about why you need this? Right now I don't see why people would want to use an extension.

Commented on link

Basically, I have an application that is a bag of mixed-technologies.  We have Castle monorail, ASP.NET Webforms, and some old custom HttpHandlers.  Currently Monorail is configured to use extension-less urls, so that means that ASP NET MVC must be mapped to an extension so the two don't overlap.

One other possibility for this need is a hosting provider that does not support extension-less URLs, but I am not sure how common that is.

I hope that makes sense!  Again, I REALLY appreciate this library; makes organizing a large project so much easier.

Commented on link

Your situation is very rare, so I'm not too excited to work on a feature that only one person would use. The hosting argument is another story, but I'm also not sure how common that would be, I think it's pretty standard for a web server to support extension-less URLs these days.

Are you sure you cannot have both Monorail and ASP.NET MVC use extension-less URLs ? Maybe if you set the routing modules in the appropriate order, the UrlRoutingModule could try to handle the request and if it can't find a route that matches it would pass control to the Monorail module. One advantage of using this library is that it creates very strict routes, so in theory it should work (I think).

If that doesn't work you'll have to download the source code and make these changes in the ControllerInfo.cs source file (Note where I added ".mvc"):

      public string UrlTemplate {
         get {
            return String.Join("/", BaseRouteSegments
               .Concat((!IsRootController) ? new[] { "{controller}" + ".mvc" } : new string[0])
            );
         }
      }

      public string ControllerUrl {
         get {
            return String.Join("/", BaseRouteSegments
               .Concat((!IsRootController) ? new[] { Name + ".mvc" } : new string[0])
            );
         }
      }

Commented on link

I understand, and thanks for showing the source that needs to be changed!