...anyway around it being "reserved"?

Topics: Administration, Installing Orchard, Troubleshooting
Mar 19, 2012 at 4:33 AM

I like the idea of the a media folder except that when a client wants to use the as a landing page for media events and the alike.  Is there a way to allow a content type to have an alias of media?

Mar 19, 2012 at 11:21 AM

Could you use the Url Rewrite module on the gallary for this?

Mar 20, 2012 at 12:52 AM

An alternative to Url Rewrite (where you can change the urls to avoid a clash with existing directory names) is to change the default setting of System.Web.Routing.RouteCollection.RouteExistingFiles.

By default this is set to false and before applying routing a check is made for an existing file or directory that matches the url - if a directory is found you get a 404 or Application Error depending upon web.config settings rather than the expected page from your controller.

You can set this to true and add a route(s) to handle (ignore) static files in MVC.

I have Orchard installed on an existing ASP website with many folders that clash with clean urls for mvc routing and have used this method to make the migration to Orchard whilst still retaining the old ASP website as a fall-back when I have to take Orchard off-line.

As a quick fix I added the following to Orchard.Web.RegisterRoutes

routes.Ignore("{*ignore}", new { ignore = @".*\.(asp|css|doc|gif|htm|ico|jpg|js|pdf|png|xls)(/.*)?" });

routes.RouteExistingFiles = true;

This ignores the static files (by dot extension) I have on the website for routing but processes urls that match directories.

There are numerous articles on configuring routing/mvc this way, phil haack (haacked,com) & stackoverflow - and potential performance improvements from eliminating the if file exists and if directory exists tests for each url with a regular expression.