Stopping ASP.NET application during Application_Start event

G

Guest

If I would like to stop an ASP.NET application after some initialization
error during the "Application_Start" event (which I have caught within a
catch clause) – what is the right way to do it?
 
J

John Timney \(ASP.NET MVP\)

You could try to add a check in session_on start to call the applications on
end event under a certain set criteria, that would allow app start to
conclude cleanly and should terminate your application.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
G

Guest

Thanks. But I didn't really understand the answer.

Calling my implementation of the event "Application_End" will have no effect
on the system. Did you mean calling another method?

Assuming that I have decided to stop the ASP.NET application what exact
method should I call?

Eric

John Timney (ASP.NET MVP) said:
You could try to add a check in session_on start to call the applications on
end event under a certain set criteria, that would allow app start to
conclude cleanly and should terminate your application.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
J

Juan T. Llibre

Restarting an Application is not doable
on the .Net Framework 1.0 nor 1.1.

In the .Net Framework 2.0, you can call Application.Restart()

For 1.0 and 1.1, you might be able to devise a workaround
which would consist of a System.IO call to "touch" your
global.asax file.

That would, in fact, restart your 1.0 or 1.1 application..

You should be careful if you want this to happen without
your intervention, whether by simply opening global.asax
in any editor and re-saving the file so that the file's date
is updated, or by running a web page which does that
( if you do that, make sure it's a password-protected page ).

The reason is that you could be starting an endless loop
( an error occurs, so the application is restarted, which
leads to the error occurring again, looping until you notice it... )




Juan T. Llibre
ASP.NET MVP
===========
Eric Dan said:
Thanks. But I didn't really understand the answer.

Calling my implementation of the event "Application_End" will have no
effect
on the system. Did you mean calling another method?

Assuming that I have decided to stop the ASP.NET application what exact
method should I call?

Eric
 
G

Guest

Thanks a lot for the answer.

Anyway I think that MS should think also of a scenario of calling
Application.Stop() in a case where the problem cannot be resolved and we
would want to prevent from entering a loop.

Eric
 
M

MattC

In that scenerio, if you are able to catch that unresolvable 'problem', you
probably should just redirect to a static error page that is simply served
up by IIS bypassing any process by ASP.NET.

MattC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top