Ria*_*son 5 c# api json .net-core .net-core-2.2
当我尝试访问任何像下面所示的代码那样构建的 API 端点时,我收到以下运行时错误:
ArgumentException: Invalid type parameter
'Microsoft.AspNetCore.Mvc.JsonResult' specified for 'ActionResult<T>'.
Run Code Online (Sandbox Code Playgroud)

此代码在 .NET Core 2.1 中的应用程序中按预期运行。升级到 .NET Core 2.2 后,这个问题就被打破了。
这是控制器中我的一个端点的代码。
[HttpGet]
public async Task<ActionResult<JsonResult>> Get()
{
try
{
MongoConnector mongo = new
MongoConnector(_configService.GetMongoConnectionString());
List<BsonDocument> queues = await mongo.AggregateQueues(
(aggregator) => aggregator
.Match(CommonAggregation.SinceYesterday)
.Sort(CommonAggregation.SortByDate)
.Group(QueueAggregators.GroupQueuesByMessagingName)
);
List<QueueHealth> queueHealth = await MongoConnector.DeserializeList<QueueHealth>(queues);
JsonResult result = new JsonResult(queueHealth);
result.Value = queueHealth;
result.ContentType = "application/json";
result.StatusCode = 200;
return result;
}
catch (Exception ex)
{
logger.Error(ex, "An exception was thrown within /api/MessageQueue");
return new StatusCodeResult(InternalServerError);
}
}
Run Code Online (Sandbox Code Playgroud)
有人知道 2.1 和 2.2 之间发生了什么变化会导致这种情况吗?我什至找不到其他人在网上提到类似的问题或有关更改的文档。