<p>I want to make an MVC route for a list of news, which can be served in several formats.</p>

<ul>
<li>news -> (X)HTML</li>
<li>news.rss -> RSS</li>
<li>news.atom -> ATOM</li>
</ul>

<p>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:</p>

<pre><code>routes.MapRoute("News-ImplicitFormat",
                "news",
                new { controller = "News", action = "Browse", format = "" });

routes.MapRoute("News-ExplicitFormat",
                "news.{format}"
                new { controller = "News", action = "Browse" });
</code></pre>

<p>It seems like it would be useful to have the routing system support something like:</p>

<pre><code>routes.MapRoute("News",
                "news(.{format})?",
                new { controller = "News", action = "Browse" });
</code></pre>

I made a method to support adding pairs like this as follows:
```
```
public static void MapRouteWithOptionalFormat(this RouteCollection routes,
                                              string name,
                                              string url,
                                              object defaults)
{
    Route implicitRoute = routes.MapRoute(name + "-ImplicitFormat",
                                          url,
                                          defaults);
    implicitRoute.Defaults.Add("format", string.Empty);

    Route explicitRoute = routes.MapRoute(name + "-ExplicitFormat",
                                          url + ".{format}",
                                          defaults);
}
```
```