我有以下API方法:
[Route("GetEditorialRequestsByCoordinates/{lat:double}/{lng:double}")]
[AutomapperExceptionApiFilterAttribute]
public HttpResponseMessage GetEditorialRequestsByCoordinates(double lat, double lng)
{
}它可以很好地满足请求,例如:
GET /v1/api/request/GetEditorialRequestsByCoordinates/48.999/2.777/但是我想增加lat和lng的限制(最小和最高)。
遵循本文:http://www.asp.net/web-api/overview/web-api-routing-and-actions/attribute-routing-in-web-api-2
max将整数与最大值匹配。{x:最多(10)} min用最小值匹配整数。{x:min(10)}
尝试创建这样的路线:
[Route("GetEditorialRequestsByCoordinates/{lat:double:min(-90):max(90)}/{lng:double:min(-180):max(180)}")]我得到404错误。为什么?
发布于 2016-03-20 20:42:19
您提供的文档告诉我们,函数适用于整型。
max: 匹配整数的最大值。 {x:max(10)}
我认为它不适用于双倍。
您可以看到这个链接来创建您自己的IHttpRouteConstraint。
https://stackoverflow.com/questions/36119037
复制相似问题