在 IIS7 上将 *.MVC 映射到 aspnet_isapi.dll
我们有一个托管在 IIS6 上的 .net 3.5 应用程序(MVC 和 WebForms 混合)。为了使其在 IIS6 上工作,我们必须向 IIS 添加自定义映射,以便 *.MVC 映射到 aspnet_isapi.dll。
所以我们的 URL 最终会是这样的:
但是现在我们在 IIS7 上设置此 Web 应用程序,使用经典模式池,我们尝试做同样的事情,这样我们就不必进行更改有关应用程序的任何信息。
但是在 IIS7 中添加 *.MVC 处理程序映射后,它似乎仍然没有拾取它。每次我们导航到 MVC 页面时,都会收到 404 错误。但是,我们的 .aspx 页面加载良好。
仔细检查后,失败请求跟踪不断抱怨以下内容 ModuleName="IIS Web Core"、Notification="MAP_REQUEST_HANDLER"、HttpStatus="404"、HttpReason="未找到"、HttpSubStatus="0"、ErrorCode="系统找不到指定的文件。 (0x80070002)", ConfigExceptionInfo=""
我在原地踏步。我们能够在另一台 IIS7 机器上设置它,但这台机器试图设置它却无法工作。我真的不知道我不知道我错过了什么,就像映射规则根本没有触发一样,因为如果我们只是在 URL 中输入随机的文件名,就会发生同样的错误。
We have a .net 3.5 application (MVC and WebForms mixed) that was hosted on IIS6. In order to make it work on IIS6 we had to add custom mappings to IIS such that *.MVC would map to aspnet_isapi.dll.
So our URL's would end up looking like this:<host>\someController.mvc\action
But now that were setting this web app up on IIS7, with classic mode pooling, were trying to do the same thing so that we don't have to change anything about the application.
But after adding the *.MVC Handler mapping in IIS7 it still does not seem to be picking it up. Every time we navigate to our MVC pages, we get 404 errors. However, our .aspx pages load fine.
On closer inspection the Failed Request Tracing keeps complaining about the followingModuleName="IIS Web Core", Notification="MAP_REQUEST_HANDLER", HttpStatus="404", HttpReason="Not Found", HttpSubStatus="0", ErrorCode="The system cannot find the file specified.
(0x80070002)", ConfigExceptionInfo=""
I'm running in circles. We were able to set this up on another IIS7 machine yet this one were trying to set it up on just refuses to work. I really don't know what I'm missing. Its like the mapping rule is not triggering at all. Because the same error occurs if we just type in random things for the file name in the URL.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚处理了这个问题,真正对我有用的是摆脱整个 MvcHttpHandler (将其从
配置标记中删除)。
MSDN 指出此处理程序仅在以下情况下有用: UrlRoutingModule 并未对所有请求启用(在 IIS7+ 中我们可以),因此它对于 IIS6 很有用(也是为什么我们需要 *.mvc 扩展名才能正确路由)。
因此,只需删除处理程序中的 MvcHttpHandler 引用,并确保:
您将 runAllManagedModulesForAllRequests 模块属性设置为“true”
如果您仍然收到 404 错误,那么可能是您的 MVC 执行了此操作(这确实让我感到困惑:S)。
I just dealt with this, and what really did it for me was getting rid of the entire MvcHttpHandler (remove it from your
configuration tag).
MSDN states that this handler is only useful when the UrlRoutingModule is not enabled for all requests (which in IIS7+ we can), hence why it's useful for IIS6 (and also why we need the *.mvc extension to route properly).
So just remove the MvcHttpHandler reference in your handlers, and make sure you:
You have the runAllManagedModulesForAllRequests modules attribute set to "true"
If you are still getting 404's then it's either your MVC doing it (which really sidetracked me :S) another reason.