gbro3n
gbro3n

Reputation: 6967

ASP.NET MVC 3 Deployment 403 Error on Windows Server 2008 R2

I'm deploying an MVC3 application to a new server. The application runs fine on the development server (Visual Studio) and also under IIS7 on my development machine, but on the server I get a 403 error:

enter image description here

I have completed the following steps, but am now out of ideas. Please help!

IUSR - Read & execute, List folder contents, Read IIS_IUSRS - Read & execute, List folder contents, Read

C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies

C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies

Upvotes: 3

Views: 4950

Answers (1)

gbro3n
gbro3n

Reputation: 6967

Ok, found the problem. Here it is incase anyone else has the same issue:

The Server I'm using must have had .NET 4 installed before IIS. This meant that .NET 4 hadn't been registered with IIS.

I noticed the issue when checking IIS config. Clicking the .NET compilation icon for the website threw an exception, presumably because the application could not be compiled.

This led me to a stack overflow post that directed me to hanselman.com

In short, I had to install VS2010 on the server so I had the Visual Studio command prompt available, and then register .NET 4 with IIS on the command line.

IIS Manager can't configure .NET Compilation on .NET 4 Applications

http://www.hanselman.com/blog/ASPNET4BreakingChangesAndStuffToBeAwareOf.aspx

Key section:

"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".

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.

Upvotes: 7

Related Questions