-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Error.razor should always be a static server rendered page #51031
Comments
I see that this was discussed by @SteveSandersonMS here: https://github.com/dotnet/aspnetcore/pull/50920/files#r1336192873 |
I tried moving Error.razor to the server project and then setting the render mode of the router dynamically based on the file path: <body>
<Routes @rendermode="@RenderModeForPage" />
<script src="_framework/blazor.web.js"></script>
</body>
</html>
@code {
[CascadingParameter] HttpContext HttpContext { get; set; } = default!;
IComponentRenderMode? RenderModeForPage => HttpContext.Request.Path.StartsWithSegments("/error")
? null
: RenderMode.InteractiveWebAssembly;
} But then I get an
It looks we might need to change the runtime to provide a way to set the render mode to static server rendering. |
Yes, I think you're right, and this is going to affect #50920 (Auth with global interactivity) because it's exactly how we're most likely going to do it. cc @halter73 The reason it worked in my PR is probably that it didn't yet have the Razor compiler changes for |
This was fixed by #51134 |
If you create new Blazor Web App with interactive WebAssembly rendering enabled globally, then the Error.razor page will get included in the client project. But this doesn't really make sense. The error page uses the HttpContext, which isn't available on the client. The error page should always be a statically rendered page from the server.
The text was updated successfully, but these errors were encountered: