try catch in global.asax file

I am maintaining some code created by a developer who has long since left the project. His documentation instructs not to place try catch blocks in the C# code,
becuase this is handled in the global asax file with a try statement. I politely disagree with
the approach. Look at the code below. It looks like it just performs cleanup after the application
ends.Plus no throw ever occurs, so the end user is not informed.




protected void Session_End(Object sender, EventArgs e)
{

   try
      {
      Custom.Project.Session.Delete(ConStr["Connection"].ToString(), Session.SessionID)
      }
   finally
   {
      Session.Abandon();
   }

}
LVL 2
brgdotnetcontractorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SriVaddadiCommented:
Well,  I encountered similar coding pattern and I think people who worked with classic ASP does this. No offense. You could use Application_error and re-direct to an error page.  Though not sure u had any question.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
brgdotnetcontractorAuthor Commented:
Hi SriVaddadi, I was pretty tired when I made this post and was not too imperative about emphasizing that I had a question. So here is my question.For the code I posted above, willl the code handlle any exception which will occur throughout the application? For example, suppose at runtime a null reference exception occurs.
0
SriVaddadiCommented:
Nope.
0
SriVaddadiCommented:
As i said earlier, Application_error or Session_Error are the events in global.asax where you could implement handler as it might be pain to implement exception handling all through the application
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.