在网址点导致404与ASP.NET MVC和IIS [英] Dots in URL causes 404 with ASP.NET mvc and IIS

查看:278
本文介绍了在网址点导致404与ASP.NET MVC和IIS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有要求我的网址都点在路径中的一个项目。例如,我可能有一个网址,如www.example.com/people/michael.phelps

I have a project that requires my URLs have dots in the path. For example I may have a URL such as www.example.com/people/michael.phelps

用点的URL生成一个404路由我是罚款。如果我通过在迈克尔·菲尔普斯,没有点,则一切正常。如果我加点,我收到了404错误。该示例站点上运行Windows 7与IIS8防爆preSS。 URLScan是没有运行。

URLs with the dot generate a 404. My routing is fine. If I pass in michaelphelps, without the dot, then everything works. If I add the dot I get a 404 error. The sample site is running on Windows 7 with IIS8 Express. URLScan is not running.

我尝试添加以下到我的web.config:

I tried adding the following to my web.config:

<security>
  <requestFiltering allowDoubleEscaping="true"/>
</security>

不幸的是没有有所作为。我刚刚收到404.0 Not Found错误。

Unfortunately that didn't make a difference. I just receive a 404.0 Not Found error.

这是一个MVC4项目,但我不认为这是相关的。我的路由工作正常,我期望的参数都在那里,直到他们有一个点。

This is a MVC4 project but I don't think that's relevant. My routing works fine and the parameters I expect are there, until they include a dot.

我需要什么配置,所以我可以有圆点在我的网址是什么?

What do I need to configure so I can have dots in my URL?

推荐答案

我通过编辑我的网站的HTTP处理程序得到了这个工作。对于我的需求这个工作得很好,我的解决问题。

I got this working by editing my site's HTTP handlers. For my needs this works well and resolves my issue.

我只是补充说,寻找特定的路径条件的新的HTTP处理程序。如果请求匹配它被正确发送到.NET进行处理。我与这个解决方案的URLRewrite黑客或启用RAMMFAR更快乐。

I simply added a new HTTP handler that looks for specific path criteria. If the request matches it is correctly sent to .NET for processing. I'm much happier with this solution that the URLRewrite hack or enabling RAMMFAR.

例如有.NET过程中的URL的 www.example.com/people/michael.phelps 以下行系统内添加到您的网站的web.config。 web服务器/处理器元素:

For example to have .NET process the URL www.example.com/people/michael.phelps add the following line to your site's web.config within the system.webServer / handlers element:

<add name="ApiURIs-ISAPI-Integrated-4.0"
     path="/people/*"
     verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS"
     type="System.Web.Handlers.TransferRequestHandler"
     preCondition="integratedMode,runtimeVersionv4.0" />

修改

有其他职位表明,要解决这个问题 RAMMFAR RunAllManagedModulesForAllRequests 。启用此选项将使所有请求所有管理模块。这意味着静态文件,如图片,PDF和其他一切由.NET进行处理时,他们并不需要的人。除非你有这方面的具体情况时,此选项最好离开。

There are other posts suggesting that the solution to this issue is RAMMFAR or RunAllManagedModulesForAllRequests. Enabling this option will enable all managed modules for all requests. That means static files such as images, PDFs and everything else will be processed by .NET when they don't need to be. This options is best left off unless you have a specific case for it.

这篇关于在网址点导致404与ASP.NET MVC和IIS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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