IIS 7 and Above
Application_Error not firing
Last post Nov 21, 2012 03:28 PM by PFMark
Nov 20, 2012 02:55 PM|PFMark|LINK
We are trying to deploy a web application to Windows 2008 server with IIS 7 but are having trouble with error handling because Application_Error in global.asax does not appear to be firing. In our development server the same code is working as we intended.
For testing, we have reduced the code to:
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
<customErrors mode="RemoteOnly" defaultRedirect="error/error.aspx"/>
With this being the error handling code, throwing an error on the development machine takes you to google.com. On the production server it takes you to error.aspx. i.e. Application_Error does not appear to be firing. We have checked that global.asax is publishing
correctly by updating the Session_Start to include a version number.
Help please, I'm totally stumped!
Nov 21, 2012 03:58 AM|HostingASPNet|LINK
I suppose that you load the site locally on the development server. Try with changing the mode="RemoteOnly" attribute on the production server.
Nov 21, 2012 06:04 AM|PFMark|LINK
Sorry, I should have mentioned that I have tried CustomErrors being On, Off and RemoteOnly. Also, I am testing remotely and locally.
Nov 21, 2012 09:34 AM|Rovastar|LINK
Have you tried comparing the tracing of the working and non-working server?
Nov 21, 2012 09:39 AM|Rovastar|LINK
Also it could it be something overwriting in the machine.config on the server? I know I often set the
deployment retail=”true” although I wouldn't expect this setting to effect it others could.
Nov 21, 2012 03:28 PM|PFMark|LINK
Thank you for all your help. I've found the problem and I'm sorry to say it was a stupid error and it cost me a day. Head. Bang. Wall. Hard.
The short explanation is that I wasn't uploading the new PrecompiledApp.config with each new build. As a result the compiled global.asax wasn't loading (although a bad test made us think it was).
The long explanation contains another question...
Our site has 500+ pages and thousands of resources -- all contained within the VS project. In most updates only a few lines of code and a few files change. From our location upload speeds are slow and a complete site upload takes more than 30 minutes. In
VS2010 we therefore "Publish" to a local folder and then manually upload only the files that have changed. As we've seen, this leaves the way open to forget a file. So the secondary question is...
What's the best way to upload only the files that change during publish? Is there a Visual Studio tool for this that I haven't seen?