This project is read-only.

Using different ErrorPage.cshtml templates depending on the requested URL?

Topics: Administration, Core, Customizing Orchard, General
Mar 24, 2015 at 3:54 PM
I am running Orchard 1.8.0 using the base url _ (there are non-Orchard elements/assets in,, etc.)

The content of the Orchard website has 4 language versions, with the first part of the content item path/url indicating the language like this: (english content) (french content) (german content)

This works fine so far for all the content pages. A problem however arises when users enter an invalid url. If by chance the invalid url matches the layer rule (say in the correct navigation and footer are shown, but in all other cases my custom ErrorPage will show no navigation and footer for the lack of a fitting layer rule. (I am aware of the default layer, but in my case setting any of the languages as "default" is not feasable.)

Is there a way to check the user's browser's language and depending on that redirect to,, etc.? Not only would that allow me to give a significant amount of users 404 pages in their language or choice including correct navigation, etc., it would also allow me to use actual content items for the 404 pages instead of - as I currently do - modify the source code of a Shape/View and push the thing to the server...

Any help is much appreciated.

(We do operate the IIS the website is running on ourselves and have full access to the configuration, if that is of any importance.)

I have created 4 Navigation Widgets for the header, and 4 Content Widgtes for the Footer, each tied to a language-specific layer (EN-Layer, FR-Layer, etc.). As Layer rule I check for the laguage part in the request URL like this:

English Layer: url("~/en-GB/*")
French Layer: url("~/fr-FR/*")
German Layer: url("~/de-DE/*")