当前位置: 动力学知识库 > 问答 > 编程问答 >

asp.net web api - ASP NET Web API 2/MVC 5 Attribute routing and constraints with forward slashes

问题描述:

We're using RavenDB on the backend and so all the DB keys are strings that contain forward slashes e.g. users/1 in /api/users/1/foo.

This question superseeds this question for the previous version of the Web API.

The solution I came up with v1 works fine but it's a little messy setting up the tables. v2 introduces attribute routing which would be a very welcome change.

However, I could find no way to match parts of the URL that contain forward slashes. I tried creating a custom constraint but it seems that the pipeline will split the URL segments before trying to match it.

What's the simplest way to extend the URL => attribute matcher such that it can accept constraints that contain full-blown regexes (i.e. not regexes limited to one segment)?

分享给朋友:
您可能感兴趣的文章:
随机阅读: