1

In the site settings of our DotNetNuke installation, we set the Default Page for "500 Error Page" as you can see below. Site Settings Default Pages DotNetNuke

After setting this, we were expecting to be redirected when an error occurs. Instead we're still redirected the the "Default.aspx?tabid=..." page.

Why isn't the correct page shown?
What do we need to change for it to work?

(We're using v9.02.00 366, .NET Framework 4.6)


EDIT: Here's how I force the error to occur using a custom module.

public partial class TriggerError500 : PortalModuleBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(UserId == -1)
        {
            throw new NotImplementedException();
        }
    }
}

This module has been placed on a public page to test the error 500 page.

Swimburger
  • 6,681
  • 6
  • 36
  • 63

4 Answers4

1

The 500 error page will most likely only be used when an exception is completely unhandled. For example, if an exception is handled by a developer, then a friendly message will be shown on the page with part of the exception in the URL. This may account for the URL thing you're seeing. It's the same page as the module in question, but in a different format.

When the exception is not handled, a visitor would ordinarily be shown the infamous "yellow screen of death" (YSOD) with error details. Depending on the settings in the web.config, the level of detail will be generic or detailed. I believe that this is the use case intended for the 500 error page. This is when you should see it.

Will Strohl
  • 1,646
  • 2
  • 15
  • 32
  • How would I force an exception to occur that's completely unhandled?Any exception thrown by a module and not handled by the module dev should trigger a error 500 page, right? – Swimburger Oct 04 '18 at 18:45
  • In looking at the source code, I don't think you can easily trigger it from within a module itself. That's pretty well insulated by the DNN framework. You'll primarily only see this if there are cascading or terminal exceptions that won't even allow the page to load. For example, something that might run the risk of shutting down your application pool. – Will Strohl Oct 04 '18 at 20:21
0

If my memory serves me right, you may want to try this in your web.config:

<customErrors mode="On" defaultRedirect="500" />
  • I just tried it, didn't change anything. I don't think the errors reach the ASP.NET error handling stack because it's being handled by DNN in an upper level. Could be wrong though, but I still get redirected to Default.aspx. – Swimburger Oct 04 '18 at 16:30
  • I believe this option is only for when you want to override the DNN functionality and use the built-in .NET feature as an alternative. – Will Strohl Oct 04 '18 at 16:55
0

A setting that will affect error handling at a platform level can be toggled in the security section

Screen Shot here

dmouseNZL
  • 16
  • 3
  • I have played with the setting, but the behavior stays the same except that it tells you to check your logs when turned on. It's off right now. – Swimburger Oct 04 '18 at 19:38
0

Due to the way that DNN handles the loading of modules, and pages, the code that you are writing does not actually trigger an HTTP 500 error, as the page itself is loaded properly. The module loading error is captured by the framework and the error is logged to the Admin Logs, but the page itself is rendered.

You typically get an HTTP 500 error when you cannot connect to the database or otherwise, in those cases the DNN will adhere to the rules.

It is possible, that you could set Response.StatusCode = 500; and then end the response and get the desired behavior, but i have NOT tested this.

Mitchel Sellers
  • 62,228
  • 14
  • 110
  • 173
  • It should trigger an HTTP 500 error in my opinion. Maybe this should be configuration option in DNN that HTTP 500 error is thrown when modules throw exceptions. If there's no connection to the database, it won't be able to load the '500' page either because it's stored in DNN. It would probably load the 500.aspx page set in CustomErrors, correct? – Swimburger Oct 05 '18 at 14:24
  • Is there any way for us to customize this behavior? – Swimburger Oct 05 '18 at 14:24