question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OnParametersSetAsync is being invoked multiple times in certain scenarios

See original GitHub issue

Describe the bug

I have a page which can be visited through out a parameter. in my case @page "/Test{CustomerId:int}"

When I visit the page with a direct link within my blazor project OnParametersSetAsync() is invoked correctly one time. However, when I visit the page manually throughout the URL bar in my browser, it gets invoked multiple times. In another project of mine, this even chains up with every page refresh but unfortunately I was not able to find out why this is happening yet.

To Reproduce

I Created this small repo which shows exactly what I mean. https://github.com/MarvinKlein1508/Blazor-ParametersSetAsync

Further technical details

  • ASP.NET Core version 5.0.2
  • VS 2020 v 16.4.8

.NET SDK (gemäß “global.json”): Version: 5.0.102 Commit: 71365b4d42

Laufzeitumgebung: OS Name: Windows OS Version: 10.0.19042 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\5.0.102\

Host (useful for support): Version: 5.0.2 Commit: cb5f173b96

.NET SDKs installed: 5.0.100-rc.2.20479.15 [C:\Program Files\dotnet\sdk] 5.0.102 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.0-rc.2.20475.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.0-rc.2.20475.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.0-rc.2.20475.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
javiercncommented, Feb 10, 2021

On _Host.cshtml

@{
   context.Response.Headers[HeaderNames.CacheControl] = "no-cache";
}
0reactions
javiercncommented, Feb 15, 2021

@MarvinKlein1508 can you point me out to where in your repro this happens?

Read more comments on GitHub >

github_iconTop Results From Across the Web

DialogFactory causing call OnParametersSet multiple times
Hi Michal,. Generally speaking, when using DialogFactory it is expected OnParametersSet to be called twice as we are adding another parameter.
Read more >
Delayed OnParametersSetAsync task triggers duplicate ...
I'm trying to avoid repetitive OnParametersSet events from triggering in child components when the parent page/component has a "long" running ...
Read more >
Parameters set and API call : r/Blazor
The problem with that is if I debug and put a breakpoint in the Params set async method I see that it's being...
Read more >
Blazor Life Cycle Events - Oversimplified
and OnParametersSetAsync() gets called again. Scenario 3: Button clicked once again and the same pattern is observed in the child component.
Read more >
ASP.NET Core Razor component lifecycle
Blazor's lifecycle event processing has changed over time and is subject to change ... OnParametersSet or OnParametersSetAsync are called:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found