How can I use MVC5 attribute-based routes with a dot/period in them?

后端 未结 2 1500
梦谈多话
梦谈多话 2021-02-10 09:13

I have basically an out-of-the box MVC 5.2 app, with attribute-based routes enabled (calling routes.MapMvcAttributeRoutes(); from the provided RouteConfig.Reg

2条回答
  •  旧巷少年郎
    2021-02-10 09:45

    We had this same issue (albeit not with attribute routing) and it started to appear in MVC 4 and continues in every version since.

    One of the contributors to our project discovered the solution. I am afraid I can't offer much of an explanation as to why, but removing and then replacing the UrlRoutingModule fixes the 404 problem when using a route with a . in it.

    
        
            
                
                
            
        
    
    

    This was discovered about 2 years ago, and so far we have not run into any negative effects caused by this change.

    BTW - If anyone has an explanation why this works, please do share.

提交回复
热议问题