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:
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.
September 22, 2010 at 2:51 pm
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.
September 22, 2010 at 9:50 pm
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.
December 21, 2010 at 9:55 pm
lifesaver. thanks!
March 8, 2011 at 8:37 am
excellent post – thanks 🙂