Changing .Net Framework version on a website in IIS without restarting the W3SVC process

If you are changing the .Net Framework version of a website hosted in IIS  you will most likely receive a message that looks like the following

The problem is that if you restart the W3SVC, all the application pools will be recycled.  In my case we are hosting multiple versions of the site in IIS (Live, Staging, etc.).  I didn’t want to recycle every application pool if I didn’t need to.  Plus, if you are storing state information in the worker process it will be lost when the application pool gets recycled.

The dialog points to a command you can run in order to keep the W3SVC process from restarting.  The command is pretty straight forward except for the “IIS-Virtual-Path” part.  The “IIS-Virtual-Path” is the path IIS uses in order to differentiate between sites.  This path is in the form “W3SVC/Site ID/root”.  To find the Site ID, just click on the “Web Sites” folder in IIS and you should see a table in the right column that looks similar to this:

IIS 6

IIS 7

Once you find the Site ID, open up a command prompt window and navigate to the folder of the framework version you are wanting to change to.  The framework version folders are usually found in c:/Windows/Microsoft.Net/Framework/.  Once you are inside the folder  you can just run the following command for a site with the ID 1957079098:

aspnet_regiis.exe -norestart -s W3SVC/1957079098/root/

After you update the framework version, you will still need to restart the application pool for the website that you are changing though.

Advertisements

4 Responses to “Changing .Net Framework version on a website in IIS without restarting the W3SVC process”

  1. Phil Moir Says:

    Really appreciate you clear and simple to solution I suddenly faced when trying to deploy new version of website today (not realising that someone had switched the target framework a couple of months ago). Worked a treat.

    The only tip, that seems pretty obvious, but maybe someone misses, is that you should run aspnet_regiis.exe in the folder of the framework version you want to switch the website to.

    • Tim Banks Says:

      Hi Phil. Thanks for your comment. I am glad the post helped you out.

      Thanks for the tip. I updated the part at the end where it talks about running the command to clarify where it should be run.

  2. David Says:

    excellent post – thanks 🙂


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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: