Reputation: 4208
I did:
Startup.cs
to Program.cs
Globals.cs
The code compiles and begins to run, but never shows anything before it explodes.
The problem
In _Host.cshtml
, the last line now throws a null reference error:
@page "/"
@namespace BEC.web.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = "_Layout";
}
<component type="typeof(App)" render-mode="ServerPrerendered" />
I know this question is hard to answer, but I'm wondering if anyone can shed a little light on where I might have gone wrong.
Upvotes: 1
Views: 171
Reputation: 30046
Define "Explodes".
My guess is its in one of the components being loaded in the "/" route. There are a few problems in error reporting that have been introduced in Net6 when, as you put it, your app explodes. See for example - https://github.com/dotnet/aspnetcore/issues/38380.
Try creating a minimal App and see what happens - no router, just some plain html output. See what happens. Then add the router, but with fixed content to see if the router is OK. I've added some code below to show you the sort of stuff to try.
@*<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
*@
@* Step 1*@
Hello World
@* Step 2*@
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
Found
</Found>
<NotFound>
Not Found
</NotFound>
</Router>
@* Step 3*@
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<StackOverflow.Server.Pages.Index />
</Found>
<NotFound>
Not Found
</NotFound>
</Router>
Upvotes: 1