I have created a simple Blazor component (.NET Core 3.1, Blazor server apps) with a public parameter:
[Parameter]
public IReadOnlyCollection<Resource> Services { get; set; }
Run Code Online (Sandbox Code Playgroud)
I fill this parameter from a .cshtml page:
<component type="typeof(ActivityView)" render-mode="ServerPrerendered" param-Services="Model.Services" />
Run Code Online (Sandbox Code Playgroud)
The model property has the same type:
public IReadOnlyCollection<Resource> Services { get; set; }
Run Code Online (Sandbox Code Playgroud)
When the instance of services is a ReadOnlyCollection(Resource), the blazor page directly runs into the following error on the client side:
Error: The list of component records …
我正在尝试将 blazor 组件包含到我的 MVC 应用程序中,但端点路由的某些内容似乎不太好。
我有一个 razor 页面(在 pages/example.cshtml 中)和一个带有视图(在 Views/Home/Index.cshtml 中)的默认控制器(在 Controllers/Home 中)。
开...
脚本调试器说: HTTP404:未找到 - 服务器未找到与请求的 URI(统一资源标识符)匹配的任何内容。(XHR)POST - https://localhost:44342/Home/_blazor/negotiate
我在启动文件中尝试了不同的东西,但无论我尝试过什么,我都无法让它工作。
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages();
services.AddServerSideBlazor();
services.AddSingleton<WeatherForecastService>();
//services.AddControllersWithViews(o => o.EnableEndpointRouting = false); -> does not change anything
services.AddMvc(o => o.EnableEndpointRouting = false);
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else …Run Code Online (Sandbox Code Playgroud) blazor ×2