ASP.NET MVC: How to Route Search Term with . (Period) at the end

后端 未结 2 1718
暗喜
暗喜 2020-12-01 21:05

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:

         


        
相关标签:
2条回答
  • 2020-12-01 21:42

    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" />
    

    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).

    0 讨论(0)
  • 2020-12-01 22:04

    If you are using .NET 4.0, you can set this flag in the system.web section of your web.config and it will be allowed:

    <httpRuntime relaxedUrlToFileSystemMapping="true" />
    

    I've tested it and it works. Haack has an explanation of it.

    0 讨论(0)
提交回复
热议问题