Get URL Params from route, without specifing @page route - Blazor
10:59 25 Oct 2023

My component wants to access the route param Foo from the url www.url.com/test?Foo=bar. However, my component does not specify the @page "..." at the top of the .razor file.

I've tried accessing the param as following, without any success:

[SupplyParameterFromQuery]
public string? Foo{ get; set; }

...

protected override async Task OnAfterRenderAsync(bool firstRender)
{
    if (firstRender)
    {
        Console.WriteLine(Foo); //outputs a blank line
    }
    ...
}

I am not sure, if the @page is the limitation, as I've read in some posts that this fixed the problem of others. Surely there must be a way to acess the url-param.

c# asp.net-core razor blazor