471,338 Members | 1,491 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

How to force an ASP.NET web app to exit?

Hi,

We have an ASP.NET web application that attempts to check some database
conditions in Application_start to ensure that all is well before the app
comes up. However, I figure out how to force the app to exit if this
verification fails. Just throwing an exception doesn't seem to do the trick.
The app still comes up.

I feel like I should be able to call Application.exit() inside of
Application_start, but of course there is no such thing here.

What is the best way to accomplish this?

thanks
Robb
Jul 21 '05 #1
3 7009
Another way to say this is, I want to abort the startup. If that clarifies
what I'm trying to do.

thanks
Robb
Jul 21 '05 #2
You cant stop and application, technically you can abort startup with an
unhandled error exception like a file not found exception.
For application exceptions, the System.Web.HttpApplication class (the base
class for Global.asax) triggers the System.Web.HttpApplication.Error event
if you do not handle the error on the page or if you re-throw the exception
and this will terminate the application as it starts.

You can open, modfy and save the web.config file which will restart the
application on next requestshould you control the exception. Best if you
handle the false start and control your application shutdown and restart
however.
--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Robb Gilmore" <Ro*********@discussions.microsoft.com> wrote in message
news:EF**********************************@microsof t.com...
Another way to say this is, I want to abort the startup. If that clarifies what I'm trying to do.

thanks
Robb

Jul 21 '05 #3
Typically, two ways to handle this:

1) your error handler would decide that the user shouldn't get access, so it
would respond with an HTML stream... effectively a web page produced by
code, that explains that an error occurred. It is good form to provide a
link to a useful home page.

2) create two virtual directories in your app: one public with an error page
(and a login page, and any other pages that are available to the general
public) and the other as an application. If the app doesn't start up,
redirect the user to the error page in the other vdir.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Robb Gilmore" <Ro*********@discussions.microsoft.com> wrote in message
news:4D**********************************@microsof t.com...
Hi,

We have an ASP.NET web application that attempts to check some database
conditions in Application_start to ensure that all is well before the app
comes up. However, I figure out how to force the app to exit if this
verification fails. Just throwing an exception doesn't seem to do the
trick.
The app still comes up.

I feel like I should be able to call Application.exit() inside of
Application_start, but of course there is no such thing here.

What is the best way to accomplish this?

thanks
Robb

Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Alberto | last post: by
2 posts views Thread by Sam Johnson | last post: by
3 posts views Thread by Robb Gilmore | last post: by
2 posts views Thread by comp.lang.php | last post: by
41 posts views Thread by Twayne | last post: by
9 posts views Thread by Patrick Sona | last post: by

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.