Clarification on how IAsyncEnumerable works with ASP.NET Web API
问题 I encountered an interesting behavior while exploring IAsyncEnumerable in an ASP.NET Web API project. Consider the following code samples: // Code Sample 1 [HttpGet] public async IAsyncEnumerable<int> GetAsync() { for (int i = 0; i < 10; i++) { await Task.Delay(1000); yield return i; } } // Code Sample 2 [HttpGet] public async IAsyncEnumerable<string> GetAsync() { for (int i = 0; i < 10; i++) { await Task.Delay(1000); yield return i.ToString(); } } Sample 1 (int array) returns {} as JSON