C# 如何从异步任务ActionResult获取返回值?
我正在尝试从一个异步任务控制器获取值到另一个控制器 我试图在条件下(!resController.Result.value)获取要处理的返回值bool,但程序读取它时出错 相反,如果我尝试在(!resController.Value)时处理C# 如何从异步任务ActionResult获取返回值?,c#,C#,我正在尝试从一个异步任务控制器获取值到另一个控制器 我试图在条件下(!resController.Result.value)获取要处理的返回值bool,但程序读取它时出错 相反,如果我尝试在(!resController.Value)时处理,则不会显示错误,但该值始终为false 第一控制器: [HttpPost("PutClient")] public async Task<ActionResult<bool>> PutClientAsync(Guid
,则不会显示错误,但该值始终为false
第一控制器:
[HttpPost("PutClient")]
public async Task<ActionResult<bool>> PutClientAsync(Guid idClient)
{
bool result = true;
try
{
result = await _ContasService.PutClientAsync(idClient);
}
catch (ExceptionWithError e)
{
_logger.LogError(e.Error.UserMessages + Environment.NewLine + e.Error.ExceptionMessage);
return Conflict(e.Error);
}
return Ok(result);
}
只需返回result
?当我调试时,我可以看到resController.result.Value
的轨迹,它具有我想要的布尔值,但无法调用到程序中。与其调用controller方法,不如调用\u ContasService.PutClientAsync(rowContratos)直接编码?只需返回result
?当我调试时,我可以看到resController.result.Value
的轨迹,它具有我想要的布尔值,但无法调用到程序中。与其调用controller方法,不如调用\u ContasService.PutClientAsync(rowContratos)代码>直接?
resController = await CuttsController.PutCUTAsync(rowContratos);
if (!resController.Result.Value)
throw new ExceptionWithError(new Error("409", "Error en el PutCUTAsync"));