简体   繁体   English

如何设置IIS6来承载ASP .NET 4 MVC4应用程序

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

I'm having a hard time configuring my server to host MVC4 application. 我很难配置服务器来托管MVC4应用程序。 Here's my situation: 这是我的情况:

  • I have Windows 2003 server SP2 我有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 到目前为止,我所有托管的应用程序都针对.NET Framework 3.5,因此使用的是ASP .NET2。我使用单个网站托管Web应用程序
  • Now, I want to host very first application targeted to ASP .NET 4 现在,我想托管第一个针对ASP .NET 4的应用程序

What I did is: 我所做的是:

  • I've installed .NET Framework 4 我已经安装了.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. 我已将新的虚拟目录添加到我的网站(托管ASP .NET 2 Web应用程序的同一网站)并将其转换为Web应用程序。 Next, I've selected ASP .NET version 4 on ASP .NET tab 接下来,在“ ASP.NET”选项卡上选择“ ASP.NET版本4”

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. 但是,当我使用根URL访问应用程序时,第一件事是403。我检查了安全选项,它们似乎还不错。 Next, I tried to access one of my controller actions, eg: 接下来,我尝试访问我的控制器操作之一,例如:

http://servername/home/index

and now I get 404 error. 现在我得到404错误。 Ok, so I've enabled browsing of files and I tried to access web.config, for to check what happens, and I received error: 好的,因此我启用了文件浏览功能,并尝试访问web.config,以检查发生了什么,并且收到错误消息:

Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. 无法加载文件或程序集'System.Core,版本= 2.0.5.0,区域性=中性,PublicKeyToken = 7cec85d7bea7798e,Retargetable =是'或其依赖项之一。 The given assembly name or codebase was invalid. 给定的程序集名称或代码库无效。 (Exception from HRESULT: 0x80131047) (来自HRESULT的异常:0x80131047)

I've also run regiis command: 我还运行了regiis命令:

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: 编辑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. 我所做的是,我从基本模板创建了一个基本的MVC4应用程序,然后将其发布到服务器中。 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. 应用程序前的启动初始化方法在类型WebActivator.ActivationManager上运行,引发异常,并显示以下错误消息:无法加载文件或程序集'System.Core,Version = 2.0.5.0,Culture = neutral,PublicKeyToken = 7cec85d7bea7798e,Retargetable = Yes或其依赖项之一。 The given assembly name or codebase was invalid. 给定的程序集名称或代码库无效。 (Exception from HRESULT: 0x80131047).] (来自HRESULT的异常:0x80131047)。

2 things I've had to do in the past to get v4 working on IIS6... 要使v4在IIS6上运行,我过去必须做的2件事...

  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 确保使用.Net 4.x版的网站在其自己的应用程序池中运行,并与使用.Net 2.x版的网站分开

  2. If you are using Razor I've noticed that IIS6 doesn't immediately know what to do. 如果您使用的是Razor,我会注意到IIS6不会立即知道该怎么做。 So you need to configure the Application Extensions Mappings. 因此,您需要配置应用程序扩展映射。 Add an extension mapping for .cshtml or .vbhtml depending on whether using C# or VB. 根据使用C#还是VB,为.cshtml或.vbhtml添加扩展名映射。 I think that's why you're getting your 404 errors. 我认为这就是为什么您遇到404错误的原因。

应用程序扩展映射

Restart IIS or recycle relevant app pools once above applied if you can to make sure changes are in effect. 如果可以确保更改生效,请重新启动IIS或回收上面应用的相关应用程序池。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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