Reputation: 5042
I'm wondering if I should make this API a non-async or somehow get await in the method body:
[Route("identity")]
[Authorize]
public class IdentityController : ControllerBase
{
[HttpGet]
public async Task<IActionResult> GetAsync() => new JsonResult(from c in User.Claims select new { c.Type, c.Value });
}
I'm not able to find a ready to use solution where JsonResult
can return awaited. Any help, remove async, or just ignore the warning?
Upvotes: 0
Views: 548
Reputation: 9492
When the async method lacks 'await' operators it will run synchronously, just as the warning says. There is no gain making it asynchronous.
To remove this warning you could make this method synchronous:
[HttpGet]
public IActionResult Get() => new JsonResult(from c in User.Claims select new { c.Type, c.Value });
Upvotes: 1