2021年1月26日星期二

How to capture the status code of an IActionResult Method return in a variable C#

I have the following method:

public IActionResult DoSomeThing()      {          try          {              Some code...          }            catch (Exception)          {              return BadRequest();          }            return Ok();      }  

I have another method from which I must capture what the DomeSomething () method returns to me in a variable:

public void OtherMethod()      {          var result = DoSomeThing();            if (result == Here I need to compare with the result, for example if it is a 200 result or Ok, do the action)          {              Do an action...           }      }  

I need to extract the status code, for example result == 200 for it to execute an action.

https://stackoverflow.com/questions/65911517/how-to-capture-the-status-code-of-an-iactionresult-method-return-in-a-variable-c January 27, 2021 at 09:06AM

没有评论:

发表评论