我有一个ASP.NET Web API(版本4)REST服务,我需要传递一个整数数组.
这是我的行动方法:
public IEnumerable<Category> GetCategories(int[] categoryIds){
// code to retrieve categories from database
}
Run Code Online (Sandbox Code Playgroud)
这是我尝试过的URL:
/Categories?categoryids=1,2,3,4
Run Code Online (Sandbox Code Playgroud) 我的asp.net核心控制器有一个简单的模型:
[HttpPost]
public async Task<DefaultResponse> AddCourse([FromBody]CourseDto dto)
{
var response = await _courseService.AddCourse(dto);
return response;
}
Run Code Online (Sandbox Code Playgroud)
我的模型是:
public class CourseDto
{
public int Id { get; set; }
public string Name { get; set; }
public string Genre { get; set; }
public string Duration { get; set; }
public string Level { get; set; }
public string AgeRange { get; set; }
public string Notes { get; set; }
public bool Active { get; set; }
public string OrganisationCode …Run Code Online (Sandbox Code Playgroud) model-binding custom-model-binder asp.net-core-mvc asp.net-core