Skip to content

Trouble with NavigateTo within OnInitialized #13582

@katiep23

Description

@katiep23

Have following code in my MainLayout.Razor page:

@inject UserState User
@inject IUriHelper uriHelper

@code {
 protected override void OnInitialized()
    {
        base.OnInitialized();
        State.PropertyChanged += OnPropertyChanged;

        if (!User.isLoggedIn)
        {
            User.redirectUrl = uriHelper.GetAbsoluteUri();
            uriHelper.NavigateTo("/Account/Login");
        }
}
}

It worked fine for me, but for others on my team, it gave them "Microsoft.AspNetCore.Components.NavigationException: 'Exception of type 'Microsoft.AspNetCore.Components.NavigationException' was thrown.'" on the uriHelper.NavigateTo line when building.

I think this is related to #11591. It shows it resolved. Is there possibly an update the rest of my team does not have? Everybody is using latest version of Visual Studio 2019 Preview & .Net Core 3.0 Preview 8

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions