title: Rules for binding query parameters in Razor Pages
body: <p>In Razor Pages, it is quite convenient that if you were to call, for example, </p>
  
  <pre><code>http://localhost/foo?bar=42
  </code></pre>
  
  <p>In the corresponding model, the <code>bar</code> key is automatically accessible in the <code>OnGet</code> constructor </p>
  
  <pre><code>public IActionResult OnGet(int bar)
  {
      System.Console.WriteLine($"bar is {bar}");
  }
  </code></pre>
  
  <p>But what if the query parameter is <code>poo</code>?</p>
  
  <pre><code>http://localhost/foo?poo=42
  </code></pre>
  
  <p>then in the model, <code>bar</code> does not get the value 42. </p>
  
  <p>So simple enough, get the variables to match the query parameter key. But what if the key is hyphenated?</p>
  
  <pre><code>http://localhost/foo?foo-bar=42
  </code></pre>
  
  <p><code>foo-bar</code> is definitely not an acceptable variable name. How do I access this query parameter? What are the rules here?</p>
  
  <p>In my specific case, I don't really have a choice but to receive these hyphenated query string parameters. Also, I'm on <code>.net core 2.2</code>. </p>