aspnetcore
aspnetcore copied to clipboard
RequestId flashed across the page
Is there an existing issue for this?
- [x] I have searched the existing issues
Describe the bug
RequestId flashed across the page
Expected Behavior
No response
Steps To Reproduce
- dotnet new blazor -ai
- dotnet run
- navigation to error page
Exceptions (if any)
No response
.NET Version
9.0.100-rc.1.24452.12
Anything else?
No response
@Varorbc thanks for contacting us.
That's been the behavior since 8.0. What's happening is that the page becomes interactive and at that point the requestId is not available. The way to handle this is to check the metadata on the App.razor component and render it statically.
Moving this to the backlog in case we decide to make improvements to the template.
That's been the behavior since 8.0.
@javiercn I noticed it works great on 8.0, but there's an issue only in 9.0
@javiercn I'm really curious why it's running twice. The first time it runs, Activity.Current is available, but the second time it's not, which causes the RequestId to show up and then disappear right away.
This only happens when navigating to the page, not when an actual error is triggered.
When an error is triggered, we always render statically, but if you navigate and have global interactivity, then the page will first render, then interactivity will start and re-render (hence the flashing).
Couple of ways to deal with this:
- Using `[PersistentState] to just persist the original TraceId. It will get rid of the flashing.
- Use https://learn.microsoft.com/en-us/aspnet/core/blazor/components/render-modes?view=aspnetcore-9.0#static-ssr-pages-in-an-interactive-app on the template code.
Separately, we should consider updating the Error page to use the Activity associated with the component host (that would work for server/client/SSR)