我有以下装饰器:
[HttpGet("{parameterType}/{parameter}/{product: int?}")]
并且函数头如下:
public IActionResult GetServices(int parameterType, string parameter, int? product= null)
我只想product
选择性地通过,但它给了我以下错误:
The constraint entry 'product' - ' int' on the route 'api/Service/{parameterType}/{parameter}/{product: int?}' could not be resolved by the constraint resolver of type 'DefaultInlineConstraintResolver'.
我怎样才能领导它?
您无需指定路由约束。代替
[HttpGet("{parameterType}/{parameter}/{product: int?}")]`
用
[HttpGet("{parameterType}/{parameter}/{product?}")]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句