Click here to Skip to main content
15,849,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, all. Could you please help with a question?

Problem: Application_Error function catches an unhandled error, but offers insufficient information to identify the source problem code.

Question: How can I shut off this error handling so that the error stops debugging at the source?

Environment: Visual Studio 2022; An ASP web app written in C#. Data is from a SQL Server.


What I have tried:

Background: I haven't coded web pages or C# in many years. I've been handed a charitable giving web solution to take over. I need to add giving paid-time-off hours. I'm copying the cash elements and changing cash to PTO.

When I do this, sometimes everything works. Other times, I hit this frustrating error which doesn't tell me where the problem came from. Instead, it stops in the Application_Error function.

At this point, you'll likely say, "What's the Error." I'd rather not say, since that will lead down a rabbit hole of trying to debug that specific error. Instead, I'd like the debugging to bomb out at the source, not in the unhandled error function.

Updated 12-Apr-23 5:03am

1 solution

I haven't tried it - I don't have a web page project handy - but you should be able to edit the Global.aspx file and add what code you want to that - there you can pick up the last error object and that should contain the info you need in terms of the exception object: How to Handle Application_error in ASP.NET App's Global.asax[^]
The Exception object can contain InnerException details as well as the file, line and stack trace where the error occurred.
Then you can add individual try...catch blocks to narrow down the problem as needed.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900