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