473,386 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Raising Exceptions in HttpApplication.Init

Upon startup of my ASP.NET 2.0 application, I check if the application
configuration is in an acceptable state inside an override of
HttpApplication.Init(). If not, I raise an exception from this method.

Everything fine so far.

But I noticed that, the next time the application gets called, the Init
method is not being called anymore, even tough it ended with an
exception the last time (which means that Init was not completed).
Instead, Session_Start is being called as if the initialisation
succeeded.

Is there a way to actually tell the ASP.NET framework that the
initialisation of the application was not successful and that it should
repeat the initialisation the next time a session is opened?

Thanks for any help
Urs

Feb 13 '06 #1
2 1665
this is all I can think of early in the morning:

Init{
TryLoadConfiguration();
}
function TryLoadConfiguration()
{
//do stuff
bool successfullyLoaded = true/false;

HttpApplication.Add("IsLoaded", successfullyLoaded );
if (!successfullyLoaded )
{
throw new exception
}
}

Application_BeginRequest (or session_start)
if (((bool)HttpApplication("IsLoaded")) == false)
{
TryLoadConfiguration();
}
in other words, keep track of whether or not you've successfully loaded in
the application variable.

One has to wonder, what is it in Init that might fail once but then suddenly
start working? Typically, if configuration stuff fails, the site should
crash until someone manually fixes it and restarts it.

Karl

--
http://www.openmymind.net/

"Urs Eichmann" <ur*@prismanet.ch> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Upon startup of my ASP.NET 2.0 application, I check if the application
configuration is in an acceptable state inside an override of
HttpApplication.Init(). If not, I raise an exception from this method.

Everything fine so far.

But I noticed that, the next time the application gets called, the Init
method is not being called anymore, even tough it ended with an
exception the last time (which means that Init was not completed).
Instead, Session_Start is being called as if the initialisation
succeeded.

Is there a way to actually tell the ASP.NET framework that the
initialisation of the application was not successful and that it should
repeat the initialisation the next time a session is opened?

Thanks for any help
Urs

Feb 13 '06 #2
Hi Karl,
thanks for your suggestion. I was hoping that there is a more "elegant"
solution which I overlooked.
ne has to wonder, what is it in Init that might fail once but then suddenly
start working? Typically, if configuration stuff fails, the site should
crash until someone manually fixes it and restarts it.


The problem is, if the configuration isn't right the site might work
for the first page, then suddenly bombing out on the next page. I want
to make sure that not even the first page is being displayed in case of
configuration errors.

Urs

Feb 13 '06 #3

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

Similar topics

8
by: leo | last post by:
Hello all - I was wondering about the performance implications of explicitly raising exceptions to get information about the current frame. Something like what the inspect module does, with: ...
16
by: Einar Høst | last post by:
Hi, I'm getting into the Trace-functionality in .NET, using it to provide some much-needed logging across dlls in the project we're working on. However, being a newbie, I'm wondering if some...
4
by: Halcyon Woodward | last post by:
I have an odd problem... We have a small development team (three coders) working on the same project (a C# web application). Each coder has a unique 'sandbox' site on a shared Windows 2003...
6
by: GiddyUpHorsey | last post by:
We have a website built on ASP.NET 2.0. We log exceptions in the Error event of Global.ASAX. We keep a getting number of random exceptions that make no sense and that we can't reproduce but happen...
8
by: Richard Collette | last post by:
When attempting to debug a webservice, I get the error: Cannot serialize member System.Exception.Data of type System.Collections.IDictionary, because it implements IDictionary. In reading...
1
by: Anonieko | last post by:
Understanding and Using Exceptions (this is a really long post...only read it if you (a) don't know what try/catch is OR (b) actually write catch(Exception ex) or catch{ }) The first thing I...
1
by: Shahar Nechmad | last post by:
I want to be able to log all exceptions that occur in the application (I'm using Enterprise Library and ASP.NET 2.0). Because with almost all exception I'm not going to do anything besides logging,...
2
by: zottty | last post by:
Dear Friends, I'm struggling with my ASP.NET/C# site. I want a default error site for all the uncaught exceptions. I tried to work it out, but no success. That's what I did: Global.asax: ...
4
by: Silfheed | last post by:
Heyas So this probably highlights my lack of understanding of how naming works in python, but I'm currently using FailUnlessRaises in a unit test and raising exceptions with a string exception. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.