Geeks With Blogs
mikedopp Geekswithblogs (edition)

If you don't know by now you can reset your web applications and or web sites with a simple change to the web.config. For example you can FTP(if remote or hosted) to your server and edit the web.config by adding a space or removing a space. Basically you want the application your using editing with think something has changed since you touched the document. Save the form after this has happened and IIS will recycle the application / web site.

This however can be tedious and just well feel like a bit of hacking. So what I have come up with is not rocket science and you most likely do not want in a easy to access area on your web form.

I add this little snippet to a button event on the form. So when ever the site needs a cleansing for what ever reason I push the button of recycle.

public bool RecycleApplication()
   {
       bool Success = true;

       //Method #1
       //   It requires high security permissions, so it may not
       //   work in your environment
       try
       {
           HttpRuntime.UnloadAppDomain();
       }
       catch (Exception ex)
       {
           Success = false;
       }

       //if (!Success)
       //{
       //    //Method #2
       //    //   By 'touching' the Web.config file, the application
       //    //   is forced to recycle
       //    try
       //    {
       //        string WebConfigPath = HttpContext.Current.Request.PhysicalApplicationPath + "\\\\Web.config";
       //        IO.File.SetLastWriteTimeUtc(WebConfigPath, DateTime.UtcNow);
       //    }
       //    catch (Exception ex)
       //    {
       //        Success = false;
       //    }
       //}

       return Success;

   }
   protected void Button1_Click(object sender, EventArgs e)
   {
       RecycleApplication();
   }

 

Once again probably not a standards compliant and not an elegant way of recycling the application / web site. However it does the job.

Posted on Sunday, March 30, 2008 5:19 AM | Back to top


Comments on this post: Resetting your web application or web site without recycling app pool or IIS.

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © mikedopp | Powered by: GeeksWithBlogs.net