Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Trapping Unhandled Errors with Global.asax

Posted on 2011-02-16
5
Medium Priority
?
740 Views
Last Modified: 2012-05-11
I'm using Global.asax to trap any unhandled errors in my aspx program.  When running on my development machine, unhandled errors are correctly trapped by Global.asax -> Application_Error.

When I publish the web site (as precompiled) and upload it to my web site, unhandled errors are no longer trapped by Global.asax.  Instead, they are displayed on the web page with the heading "Server Error in '/' Application".

My web site is hosted by Network Solutions on a Windows server using shared hosting.

Any suggestions on what I might need to do to have Global.asax process my errors rather than whatever debugger might be running under the hosting package?

Thank you in advance for your help!

George
0
Comment
Question by:CIW_George
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 9

Expert Comment

by:wellhole
ID: 34908129
Are you sure the error is not getting passed to Global.asax? Perhaps the error is actually occurring in your Global.asax handler. This is just my guess since you don't show what the error page looks like.
0
 

Author Comment

by:CIW_George
ID: 34908222
To test the unhandled error handler, I've hardcoded 'Dim x As Integer = Math.Sqrt(-1)' into my aspx program.  This should eliminate any random errors and the web error indicates that this statement is an error.

I'll be glad to post my code (it's relatively simple at this point 'cause I'm testing as I go), but I suspect the problem may be how Network Solutions' server or the VS Publisher is configured (or not...).

I do not make any changes to my code between what I'm running on my machine vs. what I publish and upload to NS.
0
 
LVL 20

Accepted Solution

by:
informaniac earned 2000 total points
ID: 34908284
Is customErrors mode="On" in web.config file?
0
 
LVL 9

Expert Comment

by:wellhole
ID: 34908311
What happens if the only thing you do in your error handler is to transfer your page to your error handling page?

Server.Transfer("~/MyErrorPage.aspx")
0
 

Author Closing Comment

by:CIW_George
ID: 34908482
Thank you informaniac!

Changing customErrors mode="On" allowed Global.asax to trap unhandled errors on the web site.
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question