Multiple optional parameters web api attribute routing

前端 未结 2 1537
余生分开走
余生分开走 2021-01-19 12:28

Hi guys i am new to attribute routing and not sure if this is even possible.

What i have is an attribute route which works fine like this

[HttpGet]
         


        
2条回答
  •  余生分开走
    2021-01-19 12:56

    Use a query string.

    [HttpGet]
        [Route("GetIssuesByFlag/{flag:int=3?}")]
        public IEnumerable GetIssuesByFlag(int flag, List tagIds, int? categoryId = null)
    

    Url: /getissuesbyflag/1?tagIds=2,5,6&categoryId=56

    You really should use query strings for optional parameters and path parameters if they are required.

提交回复
热议问题