English 中文(简体)
将拉汉多语和拉皮涅斯语移至罗马尼亚
原标题:Moving Razor Pages and Layouts to RCL

I can t seem to get why the Blazor Server Web runs with a 404 when I try to move Components/Pages and Components/Layouts from the default Blazor Server Web project to a new RCL project. Everything is at default, .NET 8.0 is used, and one thing I picked up from tutorials is to add AdditionalAssemblies to the Router:

<Router AppAssembly="@typeof(Program).Assembly" AdditionalAssemblies="new[] {typeof(ComponentLib.Components.Layout.MainLayout).Assembly, typeof(ComponentLib.Components.Pages.Home).Assembly}">
    <Found Context="routeData">
        <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/>
        <FocusOnNavigate RouteData="@routeData" Selector="h1" />
    </Found>
</Router>

Otherwise I have no idea why the 404, I tried moving the Pages dir to the root of RCL project, I tried setting copy-always for the pages and the layout files. When I "return/copy" the Components/Pages and Components/Layouts to the Blazor Web project, everything is back to normal, Hello World is displayed.

问题回答

网页似乎必须放在网络项目中,而不是RCL:

https://github.com/dotnet/aspnet/issues/49432





相关问题
Azure application service is missing .css file content

I finally have my Blazor .Net 6 application working as an Azure app service. One last problem I can t figure out, I m missing css from my project s wwwroot folder. But the font-icons are all there. ...

How to authenticate and authorize in blazor

Edit: I Answerd myself on this post. Its updated. I authenticate users using the Windows Authenticate from Blazor. Now I want to authorize these users as well, I do this by having the users roll and ...

Blazor custom validation in child component

I have this component that goes into a form like <NumberWithNAAndAmberRanges2 @bind-BindNumber="LocVM.ChartDayStartMinute" NaName="Not Applicable" NaAllowed="true&...

ILoggingBuilder - clear some providers?

I have a Blazor server web app running on Azure app services. When my code starts, as suggested, I have the following: if (builder.Environment.IsDevelopment()) { builder.Logging.ClearProviders(); ...

Blazor Server App : Unable to unprotect the message.State

I am getting an Exception as above in my Blazor server application. Below is my Program.cs File builder.Services.AddAuthentication(AzureADB2CDefaults.BearerAuthenticationScheme) .AddOpenIdConnect(...

热门标签