Restart an ASP.NET application programmatically without editing the web.config ( Reset IIS Cache)

Several times I would be working on a site and some data would not change due to session variables or the .NET cache. This can’t be eliminated by clearing the browser cache but would need the whole ASP.NET application to be restarted to clear all sessions and cache. A traditional way of doing so is to edit the web.config slightly (a space, comma, fullstop would do the trick) … however this was happening often so I decided to restart my application automatically through my code. To do so, I used the Global.ascx on application_start and added this simple line of code which restarts the ADO.NET application:

System.Web.HttpRuntime.UnloadAppDomain();

One thought on “Restart an ASP.NET application programmatically without editing the web.config ( Reset IIS Cache)

  1. Pingback: SudoAll.com | .Net Restart an ASP.NET application programmatically without editing the web.config

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s