title: Validate query parameters without using a model in .netcore api
body: <p>Is it possible to validate query parameters on an action without using a model? A lot of the calls in my API are one-offs and I don't see a point in making models for them if they will only be used one time.</p>
  
  <p>I saw the following article, which seemed like it was exactly what I needed, except I don't want it to return a 404 if the required parm doesn't exist, I want it to return an object of error messages similar to the baked in model validation - really, I just want the parameters to be treated like a model, without actually having to make a model.</p>
  
  <p><a href="https://www.strathweb.com/2016/09/required-query-string-parameters-in-asp-net-core-mvc/" rel="noreferrer">https://www.strathweb.com/2016/09/required-query-string-parameters-in-asp-net-core-mvc/</a></p>
  
  <pre class="lang-cs prettyprint-override"><code>[HttpPost]
  public async Task&lt;IActionResult&gt; Post(
      [FromQueryRequired] int? Id,
      [FromQuery] string Company)
  </code></pre>
  
  <p><strong>EDIT:</strong><br>
  The [FromQueryRequired] is a custom ActionConstraint that throws a 404 if the ID parm is missing (this was taken directly from the article). However I don't want the 404, I want an object that has a message that says {MESSAGE: "ID is required"}. I think the issue is that i can't access the Response context from within an Action Constraint.</p>