I want to make an MVC route for a list of news, which can be served in several formats.
- news -> (X)HTML
- news.rss -> RSS
- news.atom -> ATOM
Is it possible to do this (the more general "optional extension" situation crops up in several places in my planned design) with one route? Or do I need to make two routes like this:
routes.MapRoute("News-ImplicitFormat", "news", new { controller = "News", action = "Browse", format = "" }); routes.MapRoute("News-ExplicitFormat", "news.{format}" new { controller = "News", action = "Browse" });
It seems like it would be useful to have the routing system support something like:
routes.MapRoute("News", "news(.{format})?", new { controller = "News", action = "Browse" });