Last year, we moved our web applications to a new server. Here are the system/application configuration specs prior to the move:
- Windows Server 2003
- IIS 6.0
- ASP.NET 4.0
- WebForms
Here are the specs after moving to the new server:
- Windows Server 2008
- IIS 7.5
- ASP.NET 4.5.1
- WebForms/MVC 5 hybrid (thanks to VS 2013)
The problem is that, after the drastic changes in environment due to the move, the Application_Error event in Global.asax is no longer firing like it was before. I've encountered a number of questions on this (see end of this question), but none of the solutions appear to work. They are also quite old, so I think SE is due for some updated answers on this topic.
What I want to do:
If a specific exception is thrown, I want to navigate to a specific error page. Otherwise, proceeds to error.aspx
as defined in my web.config. I've made no changes to the web.config or code since the move. Here's the Application_Error event:
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
If TypeOf (Server.GetLastError) Is System.Web.HttpRequestValidationException Then
NavigateToErrorPage("Display special error message here")
End If
End Sub
customErrors
in web.config:
<customErrors mode="RemoteOnly" defaultRedirect="error.aspx" />
So what do I need to do to get my application to behave in IIS 7.5 the same way it behaved in IIS 6?
Edit: I'll note that the Application_Error event fires when running my application locally under localhost.
Other questions I've found that were unable to assist me here:
Application_Error event global.asax not getting triggered
global.asax Application_Error not firing
Application_Error not firing when customerrors = "On"
Is global.asax Application_Error event not fired if custom errors are turned on?