Get a query string parameter from a Razor Page Layout page or from a Razor Page View page.
From the Layout
var query_string_value = Context.Request.Query["key"];
if (!string.IsNullOrWhiteSpace(query_string_value))
{
//do something?
}
From the View
var query_string_value = Request.Query["key"];
if (!string.IsNullOrWhiteSpace(query_string_value))
{
//do something?
}