Attribute Routing with Multiple Leading Zero Decimals

后端 未结 2 1659
北荒
北荒 2021-01-20 22:20

Current ActionResult:

[Route(\"EvaluatorSetup/{evalYear}/{department}\")]
public ActionResult RoutedEvaluatorSetup(int evalYear, string department)
{
    ret         


        
相关标签:
2条回答
  • 2021-01-20 22:36

    Try

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

    I believe the default is int.

    0 讨论(0)
  • 2021-01-20 22:42

    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>
    
    0 讨论(0)
提交回复
热议问题