title: Required query string parameter in ASP.NET Core
body: <p>Using ASP.NET Core 1.1 with VS2015 (sdk 1.0.0-preview2-003131), I have the following controller:</p>
  
  <pre><code>public class QueryParameters
  {
      public int A { get; set; }
      public int B { get; set; }
  }
  
  [Route("api/[controller]")]
  public class ValuesController : Controller
  {
      // GET api/values
      [HttpGet]
      public IEnumerable&lt;string&gt; Get([FromQuery]QueryParameters parameters)
      {
          return new [] { parameters.A.ToString(), parameters.B.ToString() };
      }        
  }
  </code></pre>
  
  <p>As you can see, I have two query parameters. What I would like is to have one of them (ex: <code>A</code>) to be required. That is, I would like to use an attribute (if possible) to say that this attribute is required. Then, I would like like ASP.NET to do this validation before even calling my controller. </p>
  
  <p>I would have liked to use the Newtonsoft <a href="http://www.newtonsoft.com/json/help/html/JsonPropertyRequired.htm" rel="noreferrer">RequiredAttribute</a> to use the same attributes as I already use to validate the required properties in the PUT/POST content, but since the url is not a JSON string, it is obviously not used.</p>
  
  <p>Any suggestion to have ASP.NET Core automatically check for required query parameters?  </p>
  
  <p>Note that I know that I can code the check myself using nullable query parameters but that beats the purpose of letting ASP.NET do the validation before calling my controller, thus keeping my controller tidy.</p>