How to perform a clean reinstallation of IIS
I've seen several scenarios where our customers need to reinstall IIS, a typical one is related to configuration file corruption. For example, you may see following event in System Event Log:
"The configuration section 'system.webServer' cannot be read because it is missing a section declaration."
The configuration file corruption can lead to a dysfunctionalities or outages of your website/application, and instead of checking the configuration files (such as ApplicationHost.config or web.config) one by one, line by line, it's usually more efficient to reinstall the web server then the application itself.
As we are all very familiar with how to install IIS, by simply checking the box "Web Server" in Server Manager (or you can check here : link), thus naturally we'll follow the same track to uncheck the box to uninstall IIS.
But after reinstallation, we'll find the same configuration on the server: same websites, same application, and probably the same problem.
That's because the configuration files for IIS (under C:\Windows\System32\inetsrv\config) are still in place, therefore when running IIS, it reads from the old files from same place – and if this folder contains the corrupted one, then the issue will still persist.
To completely uninstall IIS, you'll need to remove the following roles:
WARNING: this manipulation will erase all your configuration on IIS. It's highly recommended to make a full backup of your server before performing this action.
Attention: A server restart is necessary after the uninstallation.
Then delete the files or rename the folder (preferred) for C:\inetpub and C:\Windows\System32\inetsrv.
Here the key step is to uninstall Windows Process Activation Service (WAS). This is the service responsible for managing application pool configuration, creating and managing lifetime of worker process for HTTP and other protocols. Once WAS uninstalled, we can safely remove the configuration files located under C:\Windows\System32\inetsrv to finally make a clean uninstallation of IIS.
To reinstall IIS, just to follow the same steps: add Web Server (IIS) as well as WAS.
You may also be interested in:
IIS Windows Process Activation Service (WAS)
IIS Configuration Reference
New features introduced in IIS 10.0