473,320 Members | 1,946 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,320 software developers and data experts.

How to force an ASP.NET web-application to exit

Hi all,

Is it possible to force an ASP.NET web-application to exit?
At application-startup I have to check and establish some
database-connections. If there an error occours, the application must
shutdown, so that at the next request the application_start section will
be reentered.

Has anyone a solution?

Greetings
Pat
Jul 1 '08 #1
9 3201
"Patrick Sona" <so**@Flexsecure.dewrote in message
news:OK**************@TK2MSFTNGP06.phx.gbl...
Hi all,

Is it possible to force an ASP.NET web-application to exit?
At application-startup I have to check and establish some
database-connections. If there an error occours, the application must
shutdown, so that at the next request the application_start section will
be reentered.

Has anyone a solution?
HttpRuntime.UnloadAppDomain() would do it.

Just to be sure the Database connections are unusual ones that can't benefit
from standard pooling techniques?

Are you sure you need such a drastic response?
--
Anthony Jones - MVP ASP/ASP.NET
Jul 1 '08 #2

What does
"establish some
database-connections"
mean?

Are you persisting them somewhere? If so, bad approach, esp in the asp.net
world.


"Patrick Sona" <so**@Flexsecure.dewrote in message
news:OK**************@TK2MSFTNGP06.phx.gbl...
Hi all,

Is it possible to force an ASP.NET web-application to exit?
At application-startup I have to check and establish some
database-connections. If there an error occours, the application must
shutdown, so that at the next request the application_start section will
be reentered.

Has anyone a solution?

Greetings
Pat

Jul 1 '08 #3
Anthony Jones schrieb:
"Patrick Sona" <so**@Flexsecure.dewrote in message
news:OK**************@TK2MSFTNGP06.phx.gbl...
>Hi all,

Is it possible to force an ASP.NET web-application to exit?
At application-startup I have to check and establish some
database-connections. If there an error occours, the application must
shutdown, so that at the next request the application_start section will
be reentered.

Has anyone a solution?

HttpRuntime.UnloadAppDomain() would do it.

Just to be sure the Database connections are unusual ones that can't benefit
from standard pooling techniques?

Are you sure you need such a drastic response?

Thanx for the quick response!
There are also some objects, which must be initialized at startup. If
there occures an error, (which should normaly not happen), then other
objects could't initialized and the application will be crash.

Thanx a lot!
Greetings
pat
Jul 1 '08 #4
your init should not be in the application startup code

as it needs to be called at other times

move the init code into a method
that inits and then sets a flag
if flag is set it does not init
now you can reset at will

Jul 1 '08 #5
"Patrick Sona" <so**@Flexsecure.dewrote in message
news:eN**************@TK2MSFTNGP06.phx.gbl...
Anthony Jones schrieb:
"Patrick Sona" <so**@Flexsecure.dewrote in message
news:OK**************@TK2MSFTNGP06.phx.gbl...
Hi all,

Is it possible to force an ASP.NET web-application to exit?
At application-startup I have to check and establish some
database-connections. If there an error occours, the application must
shutdown, so that at the next request the application_start section
will
be reentered.

Has anyone a solution?
HttpRuntime.UnloadAppDomain() would do it.

Just to be sure the Database connections are unusual ones that can't
benefit
from standard pooling techniques?

Are you sure you need such a drastic response?
Thanx for the quick response!
There are also some objects, which must be initialized at startup. If
there occures an error, (which should normaly not happen), then other
objects could't initialized and the application will be crash.
As John says doing this in the App start is probably not a good idea.

Sounds like what you need is to encase the dependant objects needed into a
'lazy' singleton pattern.

All access to the containing object is via a Static property on the object
that will instance on demand.

See: http://www.yoda.arachsys.com/csharp/singleton.html

BTW, you're happy you've got thread-safety sorted?

--
Anthony Jones - MVP ASP/ASP.NET
Jul 1 '08 #6
Anthony Jones schrieb:
"Patrick Sona" <so**@Flexsecure.dewrote in message
news:eN**************@TK2MSFTNGP06.phx.gbl...
>Anthony Jones schrieb:
>>"Patrick Sona" <so**@Flexsecure.dewrote in message
news:OK**************@TK2MSFTNGP06.phx.gbl...
Hi all,

Is it possible to force an ASP.NET web-application to exit?
At application-startup I have to check and establish some
database-connections. If there an error occours, the application must
shutdown, so that at the next request the application_start section
will
>>>be reentered.

Has anyone a solution?

HttpRuntime.UnloadAppDomain() would do it.

Just to be sure the Database connections are unusual ones that can't
benefit
>>from standard pooling techniques?

Are you sure you need such a drastic response?

Thanx for the quick response!
There are also some objects, which must be initialized at startup. If
there occures an error, (which should normaly not happen), then other
objects could't initialized and the application will be crash.

As John says doing this in the App start is probably not a good idea.

Sounds like what you need is to encase the dependant objects needed into a
'lazy' singleton pattern.

All access to the containing object is via a Static property on the object
that will instance on demand.

See: http://www.yoda.arachsys.com/csharp/singleton.html

BTW, you're happy you've got thread-safety sorted?
Thanx John and Anthony!

In normal case a singelton would be the best solution. But the objects
must be accessable from all sessions and should only be initialized at
one time. So if I realize it with the singelton-pattern, the problem is,
that each session creates its own instance. Or is that a wrong oppinion?

So my idea was, that all objects which must be have an
application-global scope are initialized at the beginning and stored in
the applicationstore.

Have you a better solution?
Greetings
Pat
Jul 2 '08 #7
sloan schrieb:
What does
"establish some
database-connections"
mean?

Are you persisting them somewhere? If so, bad approach, esp in the asp.net
world.


"Patrick Sona" <so**@Flexsecure.dewrote in message
news:OK**************@TK2MSFTNGP06.phx.gbl...
>Hi all,

Is it possible to force an ASP.NET web-application to exit?
At application-startup I have to check and establish some
database-connections. If there an error occours, the application must
shutdown, so that at the next request the application_start section will
be reentered.

Has anyone a solution?

Greetings
Pat

It means a connection to an ActiveDirectory and establish a cache for
frequently accessed objects of this AD.
Jul 2 '08 #8
"Patrick Sona" <so**@Flexsecure.dewrote in message
news:eV**************@TK2MSFTNGP05.phx.gbl...
Anthony Jones schrieb:
"Patrick Sona" <so**@Flexsecure.dewrote in message
news:eN**************@TK2MSFTNGP06.phx.gbl...
Anthony Jones schrieb:
"Patrick Sona" <so**@Flexsecure.dewrote in message
news:OK**************@TK2MSFTNGP06.phx.gbl...
Hi all,

Is it possible to force an ASP.NET web-application to exit?
At application-startup I have to check and establish some
database-connections. If there an error occours, the application must
shutdown, so that at the next request the application_start section
will
>>be reentered.

Has anyone a solution?

HttpRuntime.UnloadAppDomain() would do it.

Just to be sure the Database connections are unusual ones that can't
benefit
>from standard pooling techniques?

Are you sure you need such a drastic response?
Thanx for the quick response!
There are also some objects, which must be initialized at startup. If
there occures an error, (which should normaly not happen), then other
objects could't initialized and the application will be crash.
As John says doing this in the App start is probably not a good idea.

Sounds like what you need is to encase the dependant objects needed into
a
'lazy' singleton pattern.

All access to the containing object is via a Static property on the
object
that will instance on demand.

See: http://www.yoda.arachsys.com/csharp/singleton.html

BTW, you're happy you've got thread-safety sorted?
Thanx John and Anthony!

In normal case a singelton would be the best solution. But the objects
must be accessable from all sessions and should only be initialized at
one time. So if I realize it with the singelton-pattern, the problem is,
that each session creates its own instance. Or is that a wrong oppinion?
Yes its wrong. The singleton pattern will create only one object across the
whole application (the AppDomain). That why I asked you about thread
safety, its actually tricky stuff that comes as a bit of a surprise,
especially to former ASPers making the transition to ASP.NET.
--
Anthony Jones - MVP ASP/ASP.NET
Jul 3 '08 #9
Having only one instance will cause locking bottlenecks

Having one instance per session will likely cause excess resource
usage

I would consider using a small pool of connections

the application level lock only needs to last long enough to decide
which connection to use for the current thread

you can make it self tuning - if all connections are in use increase
the pool size
the pool which automatically reach the ideal size for performance

Jul 9 '08 #10

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

Similar topics

2
by: Jonathan Driller | last post by:
I am attempting to block repeat downloads from a site. I need to have a landing page pass a referer to a secured page. I have tried a meta refresh redirect and several Javascript redirect...
27
by: Curious Angel | last post by:
I have a resume in PDF format and I want anyone who LEFT-OR-RIGHT clicks the link to force the file to be saved, and in any event _not_ opened. Since the PDF will be in his cache in any event, I...
4
by: Kevin Muenzler, WB5RUE | last post by:
How do I force a browser to download a file instead of displaying it? In other words I have a page with MP3 and WMA files on it and I would like for the visitor to download the file instead of...
11
by: opt_inf_env | last post by:
Hello everybody, I have created a page consisting of two frames. The second frame is made to display "external" sites (i.e. written not by me, for example www.google.com). But I found that some...
17
by: Geoff Cox | last post by:
Hello, Can I use JavaScript to force a maximised window ? Thanks
3
by: Brian Henry | last post by:
Is there a way or method to make a file be saved to the computer instead of being opened on the web? we wrote a web client messaging system that uses SSL on our server and when you open a word doc...
3
by: ABC | last post by:
I have a web site include three folders: public, admin and member. I place web.config files to admin and members folders only allow admin and members to access. If there are a user login as Demo...
0
by: Raffi B. | last post by:
I want to force my C#/.net 2.0 client to use SOAP 1.1 when sending SOAP messages to my Java web service which only supports 1.1. Can I specify a setting in app.config or web.config to force SOAP...
2
by: cottonj | last post by:
is there anyway to force an event, like mouseover? I have a page that loads, and due to some complex js code (not mine) it fails to write labels to tabs until the user does a mouseover on the...
2
by: mark4asp | last post by:
Can I force the client to stop caching old stylesheets and javascript? In my dynamic web-site, I need to force the client to stop caching old versions of my stylesheets and javascript. Can I do...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.