Attribute Routing with Multiple Leading Zero Decimals

只愿长相守 提交于 2019-12-01 21:16:50
user1620220

The issue is the . in the URL.

By default, if a . is present the StaticFileHandler handles the request and looks for a filename matching the path on the file system. To override this behavior, you can assign a handler to a URL you are trying to use. For example, adding the following to your web.config:

<system.webServer>
<handlers>
  <add name="UrlRoutingHandler" path="/EvaluatorSetup/*" verb="GET" type="System.Web.Routing.UrlRoutingHandler" />
</handlers>
</system.webServer>

will force any request starting with /EvaluatorSetup/ to use the UrlRoutingHandler (the handler associated with MVC routes).

** Solution Supplement **

I found that this solution worked when I ALSO added the following to the httpRuntime element in web.config:

<system.web> 
    <httpRuntime relaxedUrlToFileSystemMapping="true" />
</system.web>

Try

[Route("EvaluatorSetup/{evalYear}/{department:string}")]

I believe the default is int.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!