問(wèn)題描述
當(dāng)我嘗試發(fā)出搜索詞以 .
(句點(diǎn))結(jié)尾的請(qǐng)求時(shí),我從 .Net MVC 收到 404 響應(yīng).這是我正在使用的路線(xiàn):
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}
);
在搜索詞中帶有 .
的搜索工作正常,只是不能以它結(jié)束.有關(guān)如何路由此搜索請(qǐng)求的任何想法?
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?
推薦答案
我已經(jīng)解決了一個(gè)類(lèi)似的問(wèn)題(我遇到了/music/R.E.M. 之類(lèi)的路徑問(wèn)題)我在 system.webServer/handlers 部分添加了以下行(根據(jù)您的情況進(jìn)行了調(diào)整):
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"/>
我也注意到了,
<httpRuntime relaxedUrlToFileSystemMapping="true" />
僅當(dāng)句點(diǎn) (.) 位于斜杠中間的某處時(shí)才有效(例如/abc/de/f),并且當(dāng)句點(diǎn)看起來(lái)像文件類(lèi)型分隔符時(shí)無(wú)效(例如/abc/de/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).
這篇關(guān)于A(yíng)SP.NET MVC:如何使用 .(期間)結(jié)束的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!