New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

DNN 404 Handling

Return to previous page

  • 4/7/2015



DNN 404 Handling

Last updated long time ago



(Enter the content of this article below)


From version 7.1 of the DNN platform, all new portals include a 404 Page.

Any URL that is requested for a site and which does not match any URL that the DNN install can match with a DNN page or other handler or service will result in the 404 Error Page being loaded, and a 404 HTTP Status being returned with the response.

This feature is installed by default on all new DNN 7.1 installations and sites created with the default template.

This feature only applies to DNN installations using a Friendly Url Provider mode of 'advanced'.

How it works

A 404 is a request that fails to match any of the following:
* A valid rewritten URL : The URL Rewriter does not recognise the URL as belonging to any DNN page or any other Rewrite rules (such as in the siteurls.config file)
* A 'physical' file on the server, where the URL maps to a valid file in the folder used for the website
* Any Http Handler or other mapped request handler on the site

If no match is found for any of the above, a HTTP 404 error will be trapped by DNN and the 404 page displayed instead.

NOTE: This is not a 404 "Redirect". No redirect occurs between the request and the return of the 404 page. The requested URL remains in the browser address line while the contents of the 404 Error Page are displayed.

Each separate Site in a DNN install has a separate 404 Error Page. This allows for individual branding of 404 pages for different sites.

Modifying the 404 Error Page

The 404 Error Page is an ordinary DNN page that can be modified with modules and skins as any other page in a DNN site. By default, it is hidden from the menu. You can either find the page in the Admin->Page Management function, or you can enter to load the page.

When it is loaded as a normal DNN page by requesting the URL, it does not return a 404 HTTP status code (instead, it returns a '200' Status code, like any other DNN page). If you are logged in as a user account with sufficient permissions, you can edit the page as normal.

Restrictions and Considerations with the DNN 404 Error Page

The 404 Error page has a few restrictions that should be considered when making changes to the page. Note that these relate to the action of returning a 404 Status code with a page, rather than anything inherent in the DNN 404 Error page - as already stated, it is just a normal DNN page configured to be the 404 Page for the specific site.

Because the 404 Error Page returns a HTTP 404, you cannot do any actions which require a Postback. This is because you cannot send a HTTP POST request to a page that doesn't exist. As such, you can't use any functions within DNN that require a postback. This includes the login/logoff functions, submitting forms (such as a search or a data input form) and any other requests for a postback.

Additionally, because of the HTTP 404 return code, the ASP.NET session object is not available. Any code that requires the Session object to be present will not work correctly.

Because of these restrictions, DNN ships with a special Skin for the 404 page which removes the Login/Logoff Skin objects to remove these functions from the page. Skin developers should create 404 specific Skin pages for their skins to assist with implementations not receiving errors.

Note that these are restrictions that apply to any 404 response page and are not restrictions within DNN itself.

Leveraging the 404 Error Page

External to DNN

It is possible to leverage the 404 Error Page from outside the DNN application. It is possible to redirect a request to the 404 Error Page, and have the page return a 404 status code. This is useful for assigning the page as an error page at the IIS or ASP.NET level.

In order to return a 404 status code for the requested 404 page, you must add a ?status=404 querystring to the end of the URL. An example would be this:
A request to the above page will return a 404 response code and show the 404 Error Page as normal, even if the 404 did not originate within the DNN Application itself. This feature is generally leveraged for returning 404 Error Pages for content that is not delivered through the DNN Framework, such as images, documents or other resources on the server.

Internal to DNN


Raising a 404 Exception within DNN should show the 404 Page as expected via the internal Exception handling.

Alternatively, the current 404 Page can be read from the Site Settings key name 'AUM_ErrorPage404', which will store the TabId. To redirect to this page, you would construct the URL for the page using the NavigateURL() function, using the correct TabId, then append the '?status=404' querystring to return the correct 404 status code.

Note that any third-party Extensions will need to recognise and return 404 Errors for malformed or incorrect URLs. For example, a Blog module which is requested with an invalid URL or non-existent Entry or Blog ID should return a 404 error when this does not match.
No sections defined
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out