473,806 Members | 2,594 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_sta rt section will
be reentered.

Has anyone a solution?

Greetings
Pat
Jul 1 '08 #1
9 3229
"Patrick Sona" <so**@Flexsecur e.dewrote in message
news:OK******** ******@TK2MSFTN GP06.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_sta rt section will
be reentered.

Has anyone a solution?
HttpRuntime.Unl oadAppDomain() 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**@Flexsecur e.dewrote in message
news:OK******** ******@TK2MSFTN GP06.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_sta rt section will
be reentered.

Has anyone a solution?

Greetings
Pat

Jul 1 '08 #3
Anthony Jones schrieb:
"Patrick Sona" <so**@Flexsecur e.dewrote in message
news:OK******** ******@TK2MSFTN GP06.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_sta rt section will
be reentered.

Has anyone a solution?

HttpRuntime.Unl oadAppDomain() 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**@Flexsecur e.dewrote in message
news:eN******** ******@TK2MSFTN GP06.phx.gbl...
Anthony Jones schrieb:
"Patrick Sona" <so**@Flexsecur e.dewrote in message
news:OK******** ******@TK2MSFTN GP06.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_sta rt section
will
be reentered.

Has anyone a solution?
HttpRuntime.Unl oadAppDomain() 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**@Flexsecur e.dewrote in message
news:eN******** ******@TK2MSFTN GP06.phx.gbl...
>Anthony Jones schrieb:
>>"Patrick Sona" <so**@Flexsecur e.dewrote in message
news:OK****** ********@TK2MSF TNGP06.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_sta rt section
will
>>>be reentered.

Has anyone a solution?

HttpRuntime.U nloadAppDomain( ) 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 applicationstor e.

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**@Flexsecur e.dewrote in message
news:OK******** ******@TK2MSFTN GP06.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_sta rt 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**@Flexsecur e.dewrote in message
news:eV******** ******@TK2MSFTN GP05.phx.gbl...
Anthony Jones schrieb:
"Patrick Sona" <so**@Flexsecur e.dewrote in message
news:eN******** ******@TK2MSFTN GP06.phx.gbl...
Anthony Jones schrieb:
"Patrick Sona" <so**@Flexsecur e.dewrote in message
news:OK******* *******@TK2MSFT NGP06.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_sta rt section
will
>>be reentered.

Has anyone a solution?

HttpRuntime.Un loadAppDomain() 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
12643
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 strategies but none pass the referer. How can I force this since the referer property is read only? I have set up an .htaccess file so it will only let people into a secure directory if they come from an internal page on my site. This is done by...
27
5094
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 would just as soon place the employer in control of what directory he wishes to save it in, and there are two salient reasons for this: 1. I want him to OWN the document 2. I want him to FIND the document, quickly, on his hard drive In any...
4
21957
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 play it without having to right-click and save. How can I force the browser to pop up the "save file as" dialog box instead of playing it? I know that I can encapsulate it in a zip file which will download and open WinZip. Thanks
11
6681
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 "external" pages (for example www.hotmail.com ) do not "want" to be displayed in my frame. They take the whole windows. Does anybody know why? Does anybody know whether this problem can be solved, i.e. whether one can force sites to be displayed...
17
1845
by: Geoff Cox | last post by:
Hello, Can I use JavaScript to force a maximised window ? Thanks
3
1720
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 as an attachment it of course opens in the browser... we want to force the user to save it to the computer (at the least give them a dialog asking what they want to do with it) instead of just opening it right to the browser... any way to do this?...
3
1307
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 which is not both admin and member roles. But it should not to access admin and member folders. I can success to limit accessing those folders, but it force users re-login screen. It is not expected to redirect to public/default.aspx. Which...
0
1013
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 1.1? Thanks, Raffi
2
5300
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 tabs. the page load event happens beforre the tabs are loaded. Once the user mouseovers the tabs, the labels of the tabs appear, and stay there. it is irritating. i would like to force a mouseover so the tab names appear. thanks
2
4309
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 this by including a querystring with the url with each external stylesheet and script file declaration? For example: <link type="text/css" rel="stylesheet" href="../images/menu.css?
0
9719
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9597
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10369
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10372
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10110
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6877
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5682
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3851
muto222
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.