How to change .NET Framework version on IIS without restarting?
If you try to change the .NET Framework version on an IIS website, it will prompt you to restart W3SVC service. In this article, I will explain how to change .NET version on IIS without restarting.
If you are here looking for the command prompt shortcut to change .NET Framework version on IIS without restarting IIS and don't want to read this full article, here is the format:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -s w3svc/881126637/root -
norestart
881126637 is the Meta ID of your website site. To learn more about this, read further.
When it is time to upgrade your website to a newer version of .NET, it is pretty straight forward to do it through the IIS Manager UI. However, the frustrating part is, it will restart the W3SVC service when you change the IIS version.
However, Microsoft has been nice to give us a warning that it is going to restart it and all your websites running on IIS will be down for few minutes. I believe it wouldn't have taken much longer to program it to integrate their own suggestion to the IIS Manager :-)
This is what IIS Manager will show if you attempt to change the .NET Framework version:
Text:
Changing the Framework version requires a restart of the W3SVC service.
Alternatively, you can change the Framework version without restarting the
W3SVC service by running: aspnet_regiis.exe -norestart -s IIS-Viirtual-Path
Do you want to continue (this will change the Framework version and
restart the W3SVC service)?
Now, Microsoft want us to go to the command prompt and type the suggested command. (I wish they had given another button there saying "click here open command command prompt!", if IIS Manager itself cannot run that command.)
The command we have to execute is pretty straight forward, but what is missing is the IIS-Virtual-Path. It took a while for me to figure out what exactly it is. I tried few times using the website name, virtual path etc, but later figured out we need to use the internal site id of the website/virtual path, which is a numberHow to find IIS Site Id?
IIS 6 and older does not show the site id of the website in the UI. There are couple of ways to find site id.
You may use the aspnet_regiis -lk command will display all Site Ids, but it will not show the website name or path. So, if you have many websites, you will not be able to figure out what website each site id represent.
Another option is, right click on your website and choose the option All Tasks > Save Configuration To a File. This step will create a text file with all the meta information of the website. Open the file and look for the site id in the following format:
<IIsWebServer Location ="/LM/W3SVC/881126637"
Note down the number from the above line and use it with the aspnet_regiis command, as shown below:
aspnet_regiis -s w3svc/881126637/root -norestart
Remember to run the aspnet_regiis from the correct version of .NET version you want the website to be registered with.
Hello Tony,
My name is Marco and I would like to ask about if this behavior is applied to an "application/virtual directory" within a web site?
I had a situation on that I changed the .Net version from 1.1 to 4.0 on an application, and, the WWW service stopped.
Could you give me some tips about how to avoid this behavior?