Question

I need to restart an app pool from code, does anyone know how to do this? I have seen many examples for iis6 and most comments have been "It doesnt work"

So any ideas, or anyway to get IIS to watch a file and when it changes have the app pool restart?

Was it helpful?

Solution

Using the application pool class would be the way to go, I think.

Kindness,

Dan

OTHER TIPS

Actually appending a single space ' ' to the end web.config will cause a Application restart.

In the web app folder (inetpub\wwwroot\webapp) create a bat file (rest.bat )with

echo   >> web.config

If you run the batch file you will get a recycle

Easier way.. Why not when the file you are looking at changes and you want to recycle the application just change a key in the Web.config. Any change to Web.config causes your application to recycle..

Rather than do it this way (recycle the pool) why not use a cache dependency based om the file? there is an example of doing it here with an xml file. That way no more app recycles.

XmlDocument urls = new XmlDocument();
        urls.Load(Server.MapPath("pathetourlfile.xml"));
        CacheDependancy dependancy = new CacheDependency(Server.MapPath("pathetourlfile.xml"))
        Cache.Insert("URLS", urls, dependency)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top