gpt4 book ai didi

C# 异步任务 返回对象

转载 作者:太空狗 更新时间:2023-10-30 00:59:40 25 4
gpt4 key购买 nike

我正在尝试使用 IActionResult 接口(interface)来抛出特定的异常。但是此刻我被困在 Controller 上了。我编写了以下代码来获得单个调用:

    [Route("singlecall")]
[HttpGet]
[ProducesResponseType(200, Type = typeof(Models.CallModel))]
[ProducesResponseType(404)]
public async Task<IActionResult> GetSingleCall([FromQuery]string callId, [FromQuery] string token)
{

CallModel singleCall = await CustomerPortalBC.CallManagementBusiness.CallService.GetSingleCall(new Guid(callId), new Guid(token));

if (singleCall == null){
return NotFound();
}

return singleCall;
}

这(显然)不起作用,因为我不能只返回 singleCall 对象。它需要一个 Microsoft.AspNetCore.Mvc.IActionResult。所以我很清楚问题是什么,只是不知道如何解决。

如有任何见解或帮助,我们将不胜感激!

最佳答案

您想返回Ok(singleCall);

关于C# 异步任务 <IActionResult> 返回对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54217311/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com