Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Razord Page specifying Parameter and SupplyParameterFromQuery for Property gives null result for Parameter

$
0
0

There are 2 routes to my .NET 8 razor page:

  1. https://localhost:7215/DemoForm/30030443-2b0c-4b94-959d-fb6132dc164f

  2. https://localhost:7215/DemoInfo?oid=30030443-2b0c-4b94-959d-fb6132dc164f

Demo.razor:

@page "/DemoForm/{rowguid:guid}"@page "/DemoInfo"@rendermode InteractiveServer<h3>Demo</h3><h1>Rowguid is @Rowguid</h1>@code {    [Parameter, SupplyParameterFromQuery(Name = "oid")]    public Guid Rowguid { get; set; }}

I expect both results to be:

Rowguid is 30030443-2b0c-4b94-959d-fb6132dc164f

However, URL 1 returns:

Rowguid is 00000000-0000-0000-0000-000000000000

URL 2 returns the expected result

Rowguid is 30030443-2b0c-4b94-959d-fb6132dc164f

If I change Demo.razor to

@page "/DemoForm/{rowguid:guid}"@page "/DemoInfo"@rendermode InteractiveServer<h3>Demo</h3><h1>Rowguid is @Rowguid</h1><h1>_oid is @_oid</h1>@code {    [Parameter]    public Guid Rowguid { get; set; }    [SupplyParameterFromQuery(Name = "oid")]    public Guid? _oid { get; set; }    protected override Task OnInitializedAsync()    {        Rowguid = _oid ?? Rowguid;        return base.OnInitializedAsync();    }}

Rowguid will have the correct results for both URLs.

So what am I missing here?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>