Skip to content

Redirection during prerendering doesn't work well #11591

@SteveSandersonMS

Description

@SteveSandersonMS

We have some logic that detects a UriHelper.NavigateTo call during prerendering, and is meant to turn it into a 302 redirection. However, trying to use this surfaced several problems:

  • It doesn't work if you try to redirect to the homepage (i.e., the base-relative URL is the empty string). I guess it's because the server-side ASP.NET Core APIs don't work in terms of base-relative URLs. Our code already knows the _baseUriString at that point in the flow, so we could fix this by calling ToAbsoluteUri and passing the result to the NavigationException.
  • For some reason, it logs the NavigationException to the console, even though our own code handles this and isn't meant to treat it as an error
  • For some reason, there's an almost 1 second delay before the redirection occurs. I determined this by disabling JS in my browser and trying to navigate to a component whose OnInit looks like this:
    protected override void OnInit()
    {
        UriHelper.NavigateTo("greeter");
    }

The browser's network tab shows the response time as ~ 1 second, even though it would be near instant if I was not redirecting to another place.

Metadata

Metadata

Labels

DoneThis issue has been fixedarea-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions