terça-feira, 4 de julho de 2023

How to get QueryString in .NET 8 Blazor using [SupplyParameterFromQuery]

To read a query string value, there is the  [Parameter] [SupplyParameterFromQuery]


@page "/"

<span>MyValue: @MyValue</span>

@code 

{

    [Parameter]

    [SupplyParameterFromQuery]

    public string MyValue { get; set; }

}


Source: Weston Walker on Twitter: "TIL in .NET Blazor you can get query strings from the URL and set them to a variable with the [SupplyParameterFromQuery] attribute. I'm finding it super handy for Oauth callback scenarios where you get a code back in the url from a external service. https://t.co/ERvhlQOlC1" / Twitter

Nenhum comentário :