ARTICLE AD BOX
Our application is a legacy ASP.NET Webforms app, we have our web.config customErrors setup like this:
<customErrors mode="RemoteOnly" defaultRedirect="/Error/Error.aspx" redirectMode="ResponseRewrite"> <error statusCode="500" redirect="/Error/ServerError.html"/> </customErrors>We also have a Default.aspx that when throwing an unhandled exception redirects to /Error.aspx.
We have been testing Error.aspx.cs by having a flag in the web.config that we check and then throw the exception, causing a redirect to Error.aspx.
Now, we also have another page that is mobile designed in the /Mobile directory named Default.aspx, and when an unhandled exception is thrown, we are also expecting it to redirect to the Error.aspx page, but it does not redirect at all. We have added many logging statements and the flow just never redirects from the mobile page.
We check the web.config in the mobile page before we throw the exception, and it has the exact same values as the regular page. We also have an Application_Error() in Global.asax.cs that logs the error message and the only thing we have in the Application_Error() is logging messages.
Is there anything we're doing wrong here or what can we do to help us figure out how to redirect the mobile page to redirect to Error.aspx?
Here's a sample of the log file for the mobile page when the exception is thrown:
// Here we check to make sure throwErrorPage flag is set to True Mobile.Default.aspx - (btn_Submit_Click) ThrowErrorPage is:True // Here, we're writing out the values from the web.config 2026-01-21 10:18:33,659 [10] DEBUG OurApplication.Mobile.Default - Method: LogAsync Mobile.Default.aspx - Mode:RemoteOnly, Default Redirect: /Error/Error.aspx, CustomErrors: StatusCode: 500, Redirect: /Error/ServerError.html; // Here we're logging on the line before throwing the exception 2026-01-21 10:18:36,818 [10] DEBUG OurApplication.Mobile.Default - Method: LogAsync Mobile.Default.aspx - (btn_Submit_Click) Throwing Exception // And here, is where the exception is being thrown 2026-01-21 10:18:42,171 [10] ERROR OurApplication.Global - Method: LogAsync Global_asax - Our Application - Unhandled Exception Exception: System.InvalidOperationException: Cannot process data in the current state at OurApplication.Mobile.Default.btn_Submit_Click(Object sender, EventArgs e) in C:\OurApplication\Mobile\Default.aspx.cs:line 174And then I get the standard exception page, it never redirects.
