title: To be able to send BadRequest Object from an extension method with Error Message String
body: <p>I am trying to return a BadRequest IHttpActionResult object from an extension method. However I am unable to use the same.</p>
  
  <p>My requirement is simply return a BadRequest error code along with my string message. </p>
  
  <p>Even If I try to use new BadRequestResult() I am unable to specify the string message that I want it to be send along with 400 error code.</p>
  
  <p>How can I pass string to BadRequestResult ... </p>
  
  <p>In other words, which method or a property I should use with BadRequestResult object that can take my message. </p>
  
  <p>PLEASE SEE: If I don't use an extension method then I can specify my message from apiController directly i.e. </p>
  
  <pre><code>IHttActionResult Get() 
  {
     return BadRequest("It has not been implemented yet");
  
  }
  </code></pre>
  
  <p>But when I want to do it in an extension method of ApiController type then I don't know any way:</p>
  
  <pre><code>  public static string ValidateRequest(this ApiController controller, object request)
              {
                  if (request != null &amp;&amp; controller.ModelState.IsValid) return null'
  
  // return here..
           }
  </code></pre>
  
  <p><strong>There is no way I could set object BadRequestResult with &lt; message >!</strong></p>
  
  <p><img src="https://i.stack.imgur.com/qucvR.png" alt="enter image description here"></p>