How to set up IIS6 to host ASP .NET 4 MVC4 application

1

I'm having a hard time configuring my server to host MVC4 application. Here's my situation:

  • I have Windows 2003 server SP2
  • Until now, all my hosted applications are targeted to .NET Framework 3.5, thus using ASP .NET 2. I use single web site to host web application
  • Now, I want to host very first application targeted to ASP .NET 4

What I did is:

  • I've installed .NET Framework 4
  • I've added new new application pool
  • I've added new virtual directory to my web site (the same web site that hosts ASP .NET 2 web apps) and converted it to web application. Next, I've selected ASP .NET version 4 on ASP .NET tab

So, I thought that it would be enough. But when I access my application with root url, the first thing I get is 403. I've checked security options and they seem to be all right. Next, I tried to access one of my controller actions, eg:

http://servername/home/index

and now I get 404 error. Ok, so I've enabled browsing of files and I tried to access web.config, for to check what happens, and I received error:

Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

I've also run regiis command:

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis.exe -s W3SVC/2049612577/root/cip-new/

but still in vain. Bottom line, it's something wrong, but I have not idea what is happening.

EDIT 1:

I've made some testing. What I did, is I'd created a basic MVC4 application from Basic template and simply published it to the server. And it worked. However when I published it to the server to the same directory, I got the error:

The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047).]

asp.net
.net
asp.net-mvc-4
razor
iis-6
asked on Stack Overflow Nov 14, 2013 by dragonfly • edited Nov 14, 2013 by Andy Davies

1 Answer

1

2 things I've had to do in the past to get v4 working on IIS6...

  1. Make sure the site using .Net version 4.x runs in it's own app pool, separate to sites using .Net version 2.x

  2. If you are using Razor I've noticed that IIS6 doesn't immediately know what to do. So you need to configure the Application Extensions Mappings. Add an extension mapping for .cshtml or .vbhtml depending on whether using C# or VB. I think that's why you're getting your 404 errors.

application extension mapping

Restart IIS or recycle relevant app pools once above applied if you can to make sure changes are in effect.

answered on Stack Overflow Nov 14, 2013 by Andy Davies

User contributions licensed under CC BY-SA 3.0