Fix blazor.web.js 404: move App.razor and Routes.razor to Host project
Root cause: App.razor was in CentralUI (Microsoft.NET.Sdk.Razor RCL) but MapRazorComponents<App>().AddInteractiveServerRenderMode() serves _framework/blazor.web.js from the host assembly (Microsoft.NET.Sdk.Web). Per MS docs, the root component must be in the server (host) project. - Move App.razor and Routes.razor from CentralUI to Host/Components/ - Add Host/_Imports.razor for Razor component usings - Make MapCentralUI generic: MapCentralUI<TApp>() accepts root component - Add AdditionalAssemblies to discover CentralUI's pages/layouts - Routes.razor references both Host and CentralUI assemblies - Fix all DI registrations (TemplateEngine services) - SCADALINK_CONFIG env var for role-specific config loading Verified: blazor.web.js HTTP 200 (200KB), login page renders with Blazor interactive server mode, SignalR circuit establishes, LDAP auth works.
This commit is contained in:
31
src/ScadaLink.Host/Components/Routes.razor
Normal file
31
src/ScadaLink.Host/Components/Routes.razor
Normal file
@@ -0,0 +1,31 @@
|
||||
<CascadingAuthenticationState>
|
||||
<Router AppAssembly="typeof(Routes).Assembly"
|
||||
AdditionalAssemblies="new[] { typeof(ScadaLink.CentralUI.Components.Layout.MainLayout).Assembly }">
|
||||
<Found Context="routeData">
|
||||
<AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(ScadaLink.CentralUI.Components.Layout.MainLayout)">
|
||||
<NotAuthorized>
|
||||
@if (context.User.Identity?.IsAuthenticated != true)
|
||||
{
|
||||
<RedirectToLogin />
|
||||
}
|
||||
else
|
||||
{
|
||||
<NotAuthorizedView />
|
||||
}
|
||||
</NotAuthorized>
|
||||
<Authorizing>
|
||||
<p class="text-muted p-3">Checking authorization...</p>
|
||||
</Authorizing>
|
||||
</AuthorizeRouteView>
|
||||
</Found>
|
||||
<NotFound>
|
||||
<LayoutView Layout="typeof(ScadaLink.CentralUI.Components.Layout.MainLayout)">
|
||||
<div class="container mt-5">
|
||||
<h3>Page Not Found</h3>
|
||||
<p class="text-muted">The requested page does not exist.</p>
|
||||
<a href="/" class="btn btn-outline-primary btn-sm">Return to Dashboard</a>
|
||||
</div>
|
||||
</LayoutView>
|
||||
</NotFound>
|
||||
</Router>
|
||||
</CascadingAuthenticationState>
|
||||
Reference in New Issue
Block a user