Here is a little problem you might run into when trying to use aspnet_regiis.exe to register ASP.NET 4 on a site.

C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -i
Start installing ASP.NET (4.0.30319).
.......
Finished installing ASP.NET (4.0.30319).
Setup has detected some errors during the operation. For details, please read the setup log file C:\Users\john\AppData\Local\Temp\ASPNETSetup_00003.log

C:\Windows\Microsoft.NET\Framework\v4.0.30319>

When you look into the mentioned log file and search for “fail” you find this:

2010-09-06 14:27:18 Failure Changing IIS ApplicationHost.config: IIS7Register failed with HRESULT 800700b7: 'Cannot create a file when that file already exists. '

So what’s that all about?

Turns out it is actually down to the fact that aspnet_regiis.exe does not cope too well with the generally accepted environment variable that expands to the Windows directory. So when you look in your applicationHost.config file (in \windows\system32\inetsrv\config) you may find something like this:

<isapiCgiRestriction>
             <add path="%windir%\system32\inetsrv\asp.dll" allowed="true" groupId="ASP" description="Active Server Pages" />
             <add path="%windir%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" allowed="true" groupId="ASP.NET v2.0.50727" description="ASP.NET v2.0.50727" />
             <add path="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" allowed="true" groupId="ASP.NET v2.0.50727" description="ASP.NET v2.0.50727" /> 
             <add path="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" allowed="true" groupId="ASP.NET v4.0.30319 (32-bit)" description="ASP.NET v4.0.30319 (32-bit)" />
             <add path="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" allowed="true" groupId="ASP.NET v4.0.30319 (32-bit)" description="ASP.NET v4.0.30319 (32-bit)" />
             <add path="%windir%\system32\inetsrv\webdav.dll" allowed="true" groupId="WEBDAV" description="WebDAV" />
</isapiCgiRestriction>

If you change the highlighted bits to the appropriate hard coded location (e.g. c:\windows ) and try again you should find it works.

HTH

Doug