结尾斜线问题在IIS 8.5 [英] trailing slash issue in IIS 8.5

查看:243
本文介绍了结尾斜线问题在IIS 8.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在从一个IIS6 ASP.NET项目(赢Server 2003中)到IIS 8.5(赢服务器2012 R2)。该项目用于下列哪些路由一些MVC组件。

We are moving a ASP.NET project from IIS6 (Win Server 2003) to IIS 8.5(Win Server 2012 R2). The project has some MVC components for which the following routing is used.

routes.MapRoute("simple", "{controller}.mvc/{action}/{id}");
routes.MapRoute(
                "Default", 
                "{controller}.mvc/{action}/{id}"                            
                new { controller = "Home", action = "Index", id = "" }
            );

于是打电话给 MyDemoController 将被MyDemo.mvc访问

Thus call to MyDemoController would be accessed by MyDemo.mvc

现在发生什么事,当我使用URL作为MyDemo.mvc /它的工作原理,但是当我使用MyDemo.mvc没有斜杠它抛出404错误。

Now what happens, when I use the url as MyDemo.mvc/ it works, but when I use MyDemo.mvc without the slash it throws 404 error.

这仅发生在部署的服务器。在我们当地的机器,它使用IIS7.5,Win 7的它工作没有任何问题。

This happens only in the deployed server. In our local machines, which use IIS7.5, Win 7 it works without any issues.

手动更改是不可能的,因为有很多添加到sitemap文件的URL和我们的客户不批准的方法。

Manually changing is not possible as there are lots of urls added to the sitemap file and our client does not approve the approach.

它是一些具体的事情到IIS版本或任何小的调整就可以解决这个问题?

Is it something specific to the IIS version or any small tweak would solve the issue?

推荐答案

看看以下。我相信这是你的问题。它与 .mvc 扩展做的。

Take a look at the following. I believe this is your problem. It has to do with the .mvc extension.

ASP.NET MVC - 路由 - 文件扩展动作

在URL 点导致404与ASP.NET MVC和IIS

的问题是,IIS将处理.mvc文件作为静态文件和
  在默认情况下,通过你的MVC没有路由假设.mvc文件
  应用。 IIS处理请求和你的MVC code永远不会获得
  更改路由到该文件。

The problem is that IIS will handle the .mvc file as a static file and will by default not route the hypothetical .mvc file through your MVC application. IIS handles the request and your MVC code never gets a change to route to this file.

总之,这里的配置是什么样子,使 .mvc 文件的工作:

In summary, here's what the configuration looks like to make .mvc files work:

<system.webServer>
  <handlers>
    <add name="MVCFileHandler"
      path="*.mvc"
      verb="GET" type="System.Web.Handlers.TransferRequestHandler"
      preCondition="integratedMode,runtimeVersionv4.0" responseBufferLimit="0"  />
  </handlers>
</system.webServer>

至于它IIS7.5,Win 7的工作没有任何问题,而不是IIS 8.5。

As for it working on IIS7.5, Win 7 without any issues and not IIS 8.5.

看看

路由的扩展在MVC4将无法正常工作一个URL,试图提供静态文件

还有&LT;模块runAllManagedModulesForAllRequests =真正的&GT; ,但
  它似乎并不为MVC4 / IIS8工作(曾经是MVC3 / IIS7 OK
  IIRC)。更多信息
  这里
  还有这一个,因为每个请求的性能影响会
  通过托管管道的路线。

There is also <modules runAllManagedModulesForAllRequests="true"> but it doesn't seem to work for MVC4/IIS8 (used to be ok in MVC3/IIS7 IIRC). More info here. There is also a performance impact with this one as every request will route through the managed pipeline.

希望这一切帮助

这篇关于结尾斜线问题在IIS 8.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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