ASP.NET MVC:如何路线搜索字词用。 (期)末 [英] ASP.NET MVC: How to Route Search Term with . (Period) at the end

查看:179
本文介绍了ASP.NET MVC:如何路线搜索字词用。 (期)末的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从净MVC中的404响应当我试图提出一个请求,其中有一个我的搜索任期结束。(期)。这是我使用的路线:

I get a 404 response from .Net MVC when I try to make a request where my search term ends with a . (period). This is the route that I'm using:

routes.MapRoute(
                "Json",
                "Remote.mvc/{action}/{searchTerm}/{count}",
                new { controller="Remote", count=10}
            );

该搜索工作正常了搜索词里面,它只是不能与它结束。任何思考如何路由这个搜索请求?

The search works fine with a . inside the search term, it just cannot end with it. Any thoughts on how to route this search request?

推荐答案

我已经解决了类似的问题(我有​​类似的路径故障/音乐/ REM) 我已经添加了下面一行到system.webServer /处理部分(扣除你的情况):

I have solved a similar issue (I had trouble with paths like /music/R.E.M.) I've added the following line into the system.webServer/handlers section (adjusted for your case):

 <add name="UrlRoutingHandler" type="System.Web.Routing.UrlRoutingHandler, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" path="Remote.mvc/*" verb="GET"/>

我也注意到,该

I've noted also, that

<httpRuntime relaxedUrlToFileSystemMapping="true" />

做的工作只有在句点(。)则介于中间的一对斜杠(例如/ ABC /德/ f)和当周期看起来像一个文件类型分隔符(不工作,例如/ ABC /德/ FG )。

does work only if the period (.) is somewhere in the middle pair of slashes (e.g. /abc/d.e/f) and does not work when the period looks like a file type separator (e.g. /abc/de/f.g).

这篇关于ASP.NET MVC:如何路线搜索字词用。 (期)末的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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