Tuesday, June 7, 2011

Setting up EC2 with an Amazon AMI (IIS 7 SQL Express 08) and "Error IIS 7.5 Detailed Error: 403.14"

Hopefully this will save someone a few hours of time in trying to figure out why your web app isn't working after creating an EC2 instance with IIS pre-installed.

So, your web site works locally, yet utterly fails to work on EC2?! So did mine, I wasnt going to do as suggested when you hit the site and turn on directory browsing, as that's obviously not what I'm after. It seemed .NET was just not 'kicking in'. Very strange, as .NET 4 & MVC3 is installed...

I searched MSDN and the best result there suggested I enable directory browsing... not quite what I'm after.

Then I found another more useful error when you go to the IIS resource manager, select your site, select ".NET compilation", I got "unrecognized element folderLevelBuildProviders".

Now we are getting somewhere! After a bit of googling, StackOverflow had the answer which links to a scott hanselman post detailing the following:

"I installed ASP.NET 4 and then installed IIS."
If you install VS2010 and/or .NET 4 first, then later install IIS, you need make sure IIS is configured to know about ASP.NET 4 otherwise IIS will have no idea how to run ASP.NET 4 applications.
There's a simple workaround:
* If you are already in this state, drop to the command line and navigate to the FX install directory. Then run "aspnet_regiis –iru".
o Note if you are on a 64-bit machine, run this command from the 64-bit FX install directory – not the 32-bit installation directory.
Or for future reference, try to enable IIS and the ASP.NET extensibility option *first* when your are building machines or VMs. That way when VS 2010 or .NET are subsequently installed, the installation will automatically detect the presence of IIS and will auto-register with it.

If you don't know what the FX install directory is, try something like: c:\windows\microsoft.net\framework64\v4.0.30319

So if you start with someone else's pre-configured VM/AMI/whatever... never assume its been setup correctly!