Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor Server: Custom 404 component causes RenderFragment error with InteractiveServer render mode

$
0
0

I'm trying to use a custom 404 component in a Blazor Server app with this router setup:

<Router AppAssembly="@typeof(App).Assembly" @rendermode="InteractiveServer"><Found Context="routeData"><RouteView RouteData="@routeData" DefaultLayout="typeof(MainLayout)" /></Found><NotFound><LayoutView Layout="typeof(MainLayout)"><NotFoundComponent /></LayoutView></NotFound></Router>

However, when I run the app, I get the following error:

An unhandled exception occurred while processing the request.InvalidOperationException: Cannot pass RenderFragment<T> parameter 'Found' to component 'Router' with rendermode 'InteractiveServerRenderMode'. Templated content can't be passed across a rendermode boundary, because it is arbitrary code and cannot be serialized.Microsoft.AspNetCore.Components.Endpoints.SSRRenderModeBoundary.ValidateParameters(IReadOnlyDictionary<string, object> latestParameters)

It seems like the @rendermode="InteractiveServer" is causing the Found template to fail. I want to display a custom 404 component, but it doesn't work with this global render mode.

Question:

How can I use a custom 404 component (NotFoundComponent) in a Blazor Server app without getting the RenderFragment<T> serialization error? Is there a different approach for defining the router or render mode that supports custom templates?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>