473,473 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Exception Handling in Global.asax

JP
I'm wondering if it's a good idea (or not) to include try-catch blocks in
the Global.asax handlers (specifically, Application_Start and
Session_Start).

So, does anyone know if I should include try-catch blocks in my Global.asax
handlers?
And, if so, what should I do with the caught exception (i.e., what do I do
in the catch block)?

Thanks.
Nov 19 '05 #1
2 1887
Max
It's fine to use them anywhere, but you have to look at what happens if
something fails -- can your users continue on their marry way without that
bit of code running? In my app, there's no way, since I'm loading up some
important global and session variables. The user will have to be directed to
a page that says the site is down. This happens for example if the site
cannot connect to the database, or there is some invalid data in the user's
login credentials. If it's possible that some users can continue on while
others cannot, I might direct the faulty users to a "call support" page, but
then you really need to track down why that's happening -- if it's something
you can test for or fix in the app then do it! Leave try/catch as a last
resort.

Just know that try/catch should NEVER be used as part of your natural
business logic. Use them only for things like a faulty network connection to
your database, where you have no control of inside the application itself.

-Max
"JP" <jp@nospam.com> wrote in message
news:Oh**************@TK2MSFTNGP10.phx.gbl...
I'm wondering if it's a good idea (or not) to include try-catch blocks in
the Global.asax handlers (specifically, Application_Start and
Session_Start).

So, does anyone know if I should include try-catch blocks in my
Global.asax
handlers?
And, if so, what should I do with the caught exception (i.e., what do I do
in the catch block)?

Thanks.

Nov 19 '05 #2
JP
Thank you, Max.
"Max" <no****@notvalid.com> wrote in message
news:eW*************@TK2MSFTNGP14.phx.gbl...
It's fine to use them anywhere, but you have to look at what happens if
something fails -- can your users continue on their marry way without that
bit of code running? In my app, there's no way, since I'm loading up some
important global and session variables. The user will have to be directed to a page that says the site is down. This happens for example if the site
cannot connect to the database, or there is some invalid data in the user's login credentials. If it's possible that some users can continue on while
others cannot, I might direct the faulty users to a "call support" page, but then you really need to track down why that's happening -- if it's something you can test for or fix in the app then do it! Leave try/catch as a last
resort.

Just know that try/catch should NEVER be used as part of your natural
business logic. Use them only for things like a faulty network connection to your database, where you have no control of inside the application itself.

-Max
"JP" <jp@nospam.com> wrote in message
news:Oh**************@TK2MSFTNGP10.phx.gbl...
I'm wondering if it's a good idea (or not) to include try-catch blocks in the Global.asax handlers (specifically, Application_Start and
Session_Start).

So, does anyone know if I should include try-catch blocks in my
Global.asax
handlers?
And, if so, what should I do with the caught exception (i.e., what do I do in the catch block)?

Thanks.


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Nenad Dobrilovic | last post by:
Hi, Is it possible for exception object to be aware of it's throwing? I want to log in the text file when exeption is thrown, not when the exception object is created (because I can create...
6
by: Jesper Ordrup Christensen | last post by:
Say I've created a piece of code that involves both sql, io and some number conversions. Being a responsible developer I have tried to catch all of the exceptions - but how can I be sure? Is...
9
by: David B | last post by:
Why is it so difficult to report bugs to Microsoft? I have a documented bug and an small test example. I don't really see why I should have to pay to tell them about it... Anyway, the...
44
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
2
by: Rajeev Soni | last post by:
Hi, Considering the scenario for handling exceptions in Web Application where we have Presentation layer, Business layer and Data Access layer; if there any exception is occurred in DAL, what is...
4
by: Frank | last post by:
Hi, I made a handler for unhandled errors. But before that is executed, VB.NET gives me the standard error window. In VB6 there was a setting (errortrapping) about handling errors in the design...
4
by: Rob Richardson | last post by:
Greetings! I am working on an application that targets a Pocket PC running Windows CE and SQL Server CE. Almost all functions in the application use a Try block with a Catch block that looks...
2
by: Nak | last post by:
Hi there, I'm just curious as to something. I have just added an exception handler at the entry point to my application, within the IDE any unhandled exceptions fallback to this and enable me...
4
by: sm | last post by:
Hi, I have a couple of questions with regards to handling errors and exceptions. 1. If I use On Error goto Errhandler ... Errhandler:
11
by: chopsnsauce | last post by:
Here's the example: Dim frm As New FORM1 Try frm.show Catch ex As Exception msgbox ex.message
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.