By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,222 Members | 1,099 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,222 IT Pros & Developers. It's quick & easy.

Using health monitoring or code to recycle the application?

P: n/a
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

--
Glyn Simpson
Money MVP
Feb 23 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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.-
Feb 23 '06 #2

P: n/a
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.

--
Regards

John Timney
Microsoft MVP

"Glyn Simpson, MVP" <gl**@serf.org> wrote in message
news:uQ**************@TK2MSFTNGP12.phx.gbl...
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

--
Glyn Simpson
Money MVP

Feb 23 '06 #3

P: n/a
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 )" <ti*****@despammed.com> wrote in message
news:O5*************@tk2msftngp13.phx.gbl...
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.

--
Regards

John Timney
Microsoft MVP

"Glyn Simpson, MVP" <gl**@serf.org> wrote in message
news:uQ**************@TK2MSFTNGP12.phx.gbl...
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

--
Glyn Simpson
Money MVP


Feb 24 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.