MVC 3 EC2 and windows 2008 R2 getting them to play nicely

I was recently migrating from using windows 2008 on AWS EC2 to using  Windows 2008 R2 when I stumbled across a problem with getting an MVC 3 app to work. I was getting the following error:

“HTTP Error 403.14 – Forbidden

The Web server is configured to not list the contents of this directory”

The EC2 windows 2008 R2 AMI’s have  .NET Framework 4 already installed so no problems there I thought but …

It all depends on the order in which you do things. On Windows 2008 I set up IIS/ ASP.Net  first then downloaded and installed the .NET 4 framework . On the Windows 2008 R2 instance I had  set up IIS / ASP.Net after  .NET 4  ( as it was already installed)  but this meant that the framework is not automatically registered  with IIS on windows 2008 R2 so you need to give it a helping hand by running aspnet_regiis -i. To do this:

Open a comamnd prompt as administrator  then do the following:

cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319

aspnet_regiis -i