Skip to content

Blazor (Server-Side) component not refreshing on navigation with multiple routes #12232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
audacity76 opened this issue Jul 16, 2019 · 2 comments
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Duplicate Resolved as a duplicate of another issue

Comments

@audacity76
Copy link

Describe the bug

If a razor component has optional parameters (multiple routes) it does not refresh if navigating from the component with parameter to the component without parameter.

To Reproduce

Steps to reproduce the behavior:

  1. Using this version of ASP.NET Core ASP.NET Core 3.0.0-preview6.19307.2
  2. Run this razor component
@page "/about"
@page "/about/{Who}"

<h1>About @(Who ?? "us")</h1>

<a href="/about">about us</a> | <a href="/about/you">about you</a> | <a href="/about/me">about me</a>

@code {
    [Parameter]
    public string Who { get; set; }
}
  1. With these arguments /about. Click on about you. Click on about us.
  2. No refresh when navigating to about us

Expected behavior

It should refresh.

@mkArtakMSFT mkArtakMSFT added area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Duplicate Resolved as a duplicate of another issue labels Jul 16, 2019
@mkArtakMSFT
Copy link
Contributor

Thanks for contacting us, @audacity76.
We plan to address this issue as part of #7419

@RemiBou
Copy link
Contributor

RemiBou commented Jul 17, 2019

This was fixed then reverted because it caused default property value to be ignored ("public int myprop {get;set;} = 2").

There is a workaround on this

 public override async Task SetParametersAsync(ParameterCollection parameters)
    {

        if (string.IsNullOrEmpty(parameters.GetValueOrDefault<string>("Who")))
        {
            Who = null;
        }

        await base.SetParametersAsync(parameters);
    }

@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Duplicate Resolved as a duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants