0
我試圖將基於視圖的應用程序更改爲API。 關閉此項目here。我不能退還OkObjectResult
。爲什麼會這樣呢,爲什麼ASP的價格是IActionResult
vs ActionResult
?不可用的OkObjectResult不能像方法一樣使用
[HttpGet]
public IActionResult Index()
{
List<ApplicationRoleListViewModel> model = new List<ApplicationRoleListViewModel>();
model = roleManager.Roles.Select(r => new ApplicationRoleListViewModel
{
RoleName = r.Name,
Id = r.Id,
Description = r.Description,
NumberOfUsers = r.Users.Count
}).ToList();
return OkObjectResult(model);
}