This project is read-only.

404 page with no theming?

Topics: Customizing Orchard, General, Writing themes
Jan 16, 2015 at 1:51 PM
I need a 404 page without the current theme applied.

I know it's possible to copy NotFound.cshtml to the theme to change the way it looks. However, it seems impossible to remove the theme altogether.

Any guidelines on how to accomplish this?
Jan 17, 2015 at 8:02 PM
In your Layout.cshtml, you can init this variable
var notFound = WorkContext.HttpContext.Response.StatusCode == (int)HttpStatusCode.NotFound;
Then, you can test this variable to do what you want, e.g not include theme styles, display only the Content zone...

Jan 28, 2015 at 12:54 PM
Thanks, that would also work!

I ended up writing a custom ThemeSelector:
public ThemeSelectorResult GetTheme(RequestContext context)
    if (requestCached) return requestCache;

    requestCached = true;

    if (context.HttpContext.Response.StatusCode == 404)
        requestCache = new ThemeSelectorResult
            Priority    = 666,
            ThemeName   = "CleanTheme"
    return requestCache;