Reputation: 213
Is there a a way to create a custom 404 page for files in the Media directory of Orchard? I would like to show a specific error messages when somebody tries to download a file from a specific path (/Media/Default/MySpecificFolder/) that no longer exists. Right now if a file does not exist it just renders a blank page.
Upvotes: 0
Views: 201
Reputation: 741
Orchard uses StaticFileHandler for images(anything in the media folder), css and js files among others. there was a chap who tried to create 'SEO' routes for assets. have a look in the modules gallery.
All said, it seems a bad idea to put assets behind too much logic in the days where more people are using CDN or buckets to provide images to their websites and alleviate the load on the server.
You could go oldskool and override the handler. i used to do it all the time, back in webforms. here is some code that seems like the real thing:StaticFileHandler
Perhaps leave the handler alone for the main web.config but override the ones in the folders you might like to serve your special 404 page.
I do not know why would you need something like that, but go for it.
thinking about it, you could create a shape that would abstract the functionality you are after. Im thinking on the sides of documents mostly, cos i still struggle with the images...
Your shape will tokenise the document in route which will pick up an id or url and if the file does not exists redirect to a 404, but if it exists just send the file.
Does it make sense?
Upvotes: 0