IActionResult vs ObjectResult vs JsonResult in ASP.NET Core API
问题 What's the best option to use in a Web API that will return both HTTP status codes and JSON results? I've always used IActionResult but it was always a Web App with a Web API. This time it's only Web API . I have the following simple method that's giving me an error that reads: Cannot implicitly convert type Microsoft.AspNetCore.Mvc.OkObjectResult to System.Threading.Tasks.Task Microsoft.AspNetCore.Mvc.IActionResult [HttpGet] public Task<IActionResult> Get() { return Ok(); } 回答1: Return the