ASP.NET 4.5 MVC 4 不适用于 Windows Server 2008 IIS 7 [英] ASP.NET 4.5 MVC 4 not working on Windows Server 2008 IIS 7

查看:40
本文介绍了ASP.NET 4.5 MVC 4 不适用于 Windows Server 2008 IIS 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

显然我遗漏了一些东西,我无法在 IIS 7 上的 Windows Small Business Server 2008 上部署简单的 ASP.NET MVC 4、.NET 4.5 应用程序.

Clearly I'm missing something, I'm unable to deploy a simple ASP.NET MVC 4, .NET 4.5 app on a Windows Small Business Server 2008 on IIS 7.

.NET 框架 4.5 已安装.

.NET framework 4.5 is installed.

我应该在应用程序的应用程序池基本设置中看到那个版本 (4.5) 吗?这个时候我只有2.0和4.0,因为4.5就像3.5只是在4.0框架之上加的,我想这是正常的.

Should I be supposed to see that version (4.5) on the Application Pool basic settings of the application? At this time, I only have 2.0 and 4.0, since 4.5 is like the 3.5 which only add on top of the 4.0 framework, I guess this is normal.

当我浏览主页时,出现以下错误:

When I browse the home page, I got the following error:

403 - 禁止:访问被拒绝.您无权使用您提供的凭据查看此目录或页面.

403 - Forbidden: Access is denied. You do not have permission to view this directory or page using the credentials that you supplied.

当我请求名为 Page/page/index 的唯一控制器时,我得到 404 not found 页面.就像 ASP.NET 进程永远不会得到 http 请求一样.

When I request the only controller named Page /page/index I get the 404 not found page. Like the ASP.NET process never get the http request.

我可以请求一个简单的 HTML 页面.

I can request a simple HTML page.

应用程序池设置为 .NET 4.0 并集成为托管管道模式.

The Application Pool is set to .NET 4.0 and Integrated as the Managed pipeline mode.

NETWORK SERVICE 对该目录具有读/写访问权限.

NETWORK SERVICE has read/write access to the directory.

该应用程序当然可以在 VS2012 中完美运行.

The app work flawlessly from VS2012 of course.

我对这里的问题一无所知,搜索引擎查询也无济于事.

I'm clueless on what's not right here, and search engine queries are not helping much.

有没有人有提示,那将不胜感激.谢谢

Does anyone would have a hint, that would be extremely appreciated. Thanks

编辑

dll 已经在 bin 文件夹中,如 System.Web.Mvc、System.Web.Razor 等

The dlls are already on the bin folder like System.Web.Mvc, System.Web.Razor etc.

我创建了一个空的 test.aspx 页面,以确保 asp.net 工作进程正在接收请求,是的,页面没问题.所以看起来 MVC 路由不起作用,尽管我有 ASP.NET MVC 3 web 应用程序在该服务器上正常工作.

I created a empty test.aspx page to make sure asp.net worker process was getting the request, and yes the page was OK. So it appears that the MVC routing is not working, though I have ASP.NET MVC 3 web app working fine on that server.

在 .NET 4.5 安装之后,我做了一个 aspnet_regiis -iru,以防万一,在应用程序上添加了一个 aspnet_client 文件夹,但这仍然不能解决问题.

After the .NET 4.5 installation I did a aspnet_regiis -iru in case, that added an aspnet_client folder on the app, but still this does not fix the issue.

匿名身份验证在 IIS 身份验证部分启用,授权显示允许所有用户.

Anonymous Authentication is Enable on IIS Authentication section, and Authorization show allow for all users.

ASP.NET MVC 4 已安装,我只是进行了修复以确保.

ASP.NET MVC 4 is installed, I just did a repair to make sure.

即使安装了 ASP.NET MVC 4,请求/page/index 操作的 404 错误也是由标准 IIS 返回的,而不是标准的 aspnet 错误.所以确实看起来MVC 4框架没有正确安装,我只是仔细检查并进行修复.我可以在哪里继续调查?

Eventhough the ASP.NET MVC 4 is installed, the 404 error from requesting the /page/index action is returned by the standard IIS and not the standard aspnet error. So indeed it appears like the MVC 4 framework is not properly installed, by I just double check and do a repair. Where can I continue to investigate?

@Mystere Man,我已将匿名身份验证更改为使用应用程序池身份,停止、启动应用程序,但仍然出现相同的错误.看起来真的就像 ASP.NET MVC 4 没有接受请求一样.

@Mystere Man, I've changed the Anonymous Authentication to use the Application Pool identity, stop, start the app and still the same error. It really look like if ASP.NET MVC 4 is not taking the request.

这是 web.config 的一部分:

Here is a part of the web.config:

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="*" modules="IsapiModule" scriptProcessor="%windir%Microsoft.NETFrameworkv4.0.30319aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="*" modules="IsapiModule" scriptProcessor="%windir%Microsoft.NETFramework64v4.0.30319aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>

编辑 2012/09/27

Edit 2012/09/27

我重新配对了 Microsoft Framework .NET 4.5 并修复了 ASP.NET MVC 4,重新部署了简单的 ASP.NET MVC 4 应用程序,但我仍然得到相同的行为.我不知道接下来要做什么,所以我开始悬赏,希望有人能帮我找到问题.

I've re-pair Microsoft Framework .NET 4.5 and repair the ASP.NET MVC 4, re-deploy the simple ASP.NET MVC 4 app, and I still get the same behaviour. I'm not sure what to do next, so I started a bounty in the hope that someone could help me find the problem.

编辑 2014/01/31

当我问这个问题时,我将 runAllManagedModulesForAllRequests 标记为已接受的答案,因为它确实解决了问题.但我当然不会在生产中使用它.我问为什么我必须这样做,但没有任何答案.

When I asked that question, I flagged the runAllManagedModulesForAllRequests as the accepted answer because it did solve the problem. But I was certainly not going to use this in production. I ask why I had to do this and did not have any answers.

Martin Hollingsworth 答案确实是我一直在寻找的,这是在没有所有性能的情况下解决此问题的好方法与 runAllManagedModulesForAllRequests 相关的问题.

Than Martin Hollingsworth answer was really what I was looking for, a good way to fix this problem without all the performance issues related to the runAllManagedModulesForAllRequests.

我们几乎放弃并购买了一个新的 Windows 2012 服务器(ASP.NET MVC 应用程序从它那里工作).在尝试了 Martin 的解决方案后,Windows 2008 服务器可以工作了.

We almost gave up and bought a new Windows 2012 server (from which the ASP.NET MVC app work as is). After trying Martin's solution, the Windows 2008 server worked.

推荐答案

如果您不能申请来自 kb 980368 的 QFE,而不是使用已接受的 answer,您应该使用带有 preCondition="" 的模块配置,以避免对博客文章中所述的静态内容产生负面影响 http://blogs.msdn.com/b/tmarq/archive/2010/04/01/asp-net-4-0-enables-routing-of-extensionless-urls-without-impacting-static-requests.aspx"rel="nofollow noreferrer">asp.NET MVC 路由的工作原理及其对静态请求性能的影响让你的 MVC 路由工作时不要使用 runAllManagedModulesForAllRequests="true" 和一些对答案的评论.

If you are not able to apply the QFE from kb 980368, instead of using the runAllManagedModulesForAllRequests solution as suggested in the accepted answer, you should use the modules configuration with preCondition="" shown below to avoid the negative impact on static content as described in the blog posts How asp.NET MVC Routing Works and its Impact on the Performance of Static Requests and Don't use runAllManagedModulesForAllRequests="true" when getting your MVC routing to work and some of the comments on the answers.

Scott Hanselman 的关于 runAllManagedModulesForAllRequests 的博客文章 应该增加一些权重.Rick Strahl 的 帖子 使用 IIS 7/8 中的 runAllManagedModulesForAllRequests 的警告 是最好的解释我发现的设置之间的相互作用.关于 module preCondition 属性的 IIS 文档 也值得一读.

Scott Hanselman's blog post about runAllManagedModulesForAllRequests should add some weight to this argument. Rick Strahl's post Caveats with the runAllManagedModulesForAllRequests in IIS 7/8 is the best explanation of the interaction between the settings I have found. The IIS documentation on the module preCondition attribute is also worth a read.

请记住,如果您已应用 QFE,则无需进行此配置更改,因为此行为已成为默认设置.

Remember this configuration change is not necessary if you have applied the QFE as this behaviour becomes the default.

<system.webServer>
  <modules>
    <remove name="UrlRoutingModule-4.0" />
    <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
  </modules>
</system.webServer>

这篇关于ASP.NET 4.5 MVC 4 不适用于 Windows Server 2008 IIS 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆