Optional Parameters in Web Api Attribute Routing

后端 未结 3 1540
小鲜肉
小鲜肉 2020-12-01 11:56

I want to handle POST of the following API-Call:

/v1/location/deviceid/appid

Additional Parameter are coming from the Post-Body.

This al

3条回答
  •  -上瘾入骨i
    2020-12-01 12:07

    Another info: If you want use a Route Constraint, imagine that you want force that parameter has int datatype, then you need use this syntax:

    [Route("v1/location/**{deviceOrAppid:int?}**", Name = "AddNewLocation")]
    

    The ? character is put always before the last } character

    For more information see: Optional URI Parameters and Default Values

提交回复
热议问题