Using health monitoring or code to recycle the application?

G

Glyn Simpson, MVP

Hi

I've got an ASP.NET 2.0 application, and I would like to catch the scenario
of when I get a certain number of application errors, I want to restart the
application (similar to 'touching' web.config).

However, I don't have access to IIS, nor can I FTP in a new web.config file
to force the application to restart.I can't see any way at the moment to do
this through code, which would be good, as I can then restart it remotely
(through a web handler).

Is there any way in code that I can do this, either through health
monitoring for it to happen automatically, or through other code (perhaps
with me putting in my authentication details that I use to upload the site)
that can force an application restart?

Thanks in advance..

Glyn
 
S

Spartaco

Is there any way in code that I can do this, either through health
monitoring for it to happen automatically, or through other code (perhaps
with me putting in my authentication details that I use to upload the
site) that can force an application restart?

this is a trick: whenever you want your appdomain recycled, create a file
named App_Offline.htm inside the root of your application, wait 1 second,
asp.net will notice the file and recycle automatically, then cancel the file
or all of the requests will be redirected to this static file, and I'm sure
this is not what you want :) by the way this trick is also used by vs.2005

spa.-
 
J

John Timney \( MVP \)

Glyn,

I've not used it myself, but you can use the new
WebConfigurationManager.OpenWebConfiguration Method, which give you write
access to web.config to touch the web.config and force a safe restart of the
application.

Whats interesting in your scenario is that you can do it from another web
application.
 
G

Glyn Simpson, MVP

Thanks John and Spartaco

I am investigating using rewriting the web.config file, and programmatic
impersonation (http://west-wind.com/weblog/posts/1572.aspx) to do it and it
looks like, on initial tests I am able to remotely restart the application.
So i'm now halfway to the desired solution of a fully automatic restart.
I'll do a bit more reading up on the health monitoring to see if I can go
the whole hog, but if not, the halfway point helps enormously.

Thanks!

--
Glyn Simpson
Money MVP


I do not respond to any unsolicited email regarding Money
John Timney ( MVP ) said:
Glyn,

I've not used it myself, but you can use the new
WebConfigurationManager.OpenWebConfiguration Method, which give you write
access to web.config to touch the web.config and force a safe restart of
the application.

Whats interesting in your scenario is that you can do it from another web
application.
 

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,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top