简体   繁体   中英

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:

在此处输入图像描述

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

  • Using the same xcopy deployment technique that I used on my development machine, I have deployed files to the to the server and added the following permissions to the folder:

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

  • I have also installed ASP.NET MVC3 on server so additional required.dlls are in GAC

  • IIS is set up and I can access basic html files (such as test.html that I have dropped in at the site route).

  • I have checked in Server Manager that all Role Services are installed

  • Have attempted to bin deploy by copying files from MVC install location and putting in the bin directory

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM