title: WebApi: Creating custom BadRequest status outside of ApiController
body: <p>Using .NET Core 2.0 WebApi.</p>
  
  <p>I have a webapi which has many endpoints where each endpoint is handling and throwing BadRequest when it fails. As below:</p>
  
  <pre><code>if(data == null)
  {
     return BadRequest("Data must not be blank.");
  }
  </code></pre>
  
  <p>Now since these status codes are repetitive in my api, I was thinking to create a Helper method which would return BadRequest back to my API.</p>
  
  <p>So I created a static helper class. But the issue here is BadRequest is part of ControllerBase and is not available in my helper class. What is the best way to create this method that would return a BadRequest.</p>
  
  <p>--Updated---</p>
  
  <p>I want something like this:</p>
  
  <pre><code>    public static BadRequest GetBadRequestMessage(string message)
      {
          return BadRequest(message);
      }
  </code></pre>
  
  <p>I have also tried as:</p>
  
  <pre><code>    public static BadRequestResult GetBadRequestMessage(string message)
      {
          return new  BadRequestResult(message);
      }
  </code></pre>
  
  <p>But this gives error: Severity  Code    Description Project File    Line    Suppression State
  Error   CS1729  'BadRequestResult' does not contain a constructor that takes 1 arguments    </p>