我有一个asp.net 6的应用程序,我想要添加一个服务器端的blazor组件。我已经设置好了我的程序,我正在调用我的组件,但是当我导航到页面时,它找不到静态的blazor文件,因为它放在路由中。我该如何解决这个问题?
此外,我可以正确地使用静态和ServerPrerendered渲染模式,但无法使用Server模式,因为它需要JS。
在我的首页上:
此外,我可以正确地使用静态和ServerPrerendered渲染模式,但无法使用Server模式,因为它需要JS。
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddHttpContextAccessor();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
app.MapBlazorHub();
app.Run();
_Layout.cshtml
<script src="~/_framework/blazor.server.js"></script>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false)
搜索组件调用:
<component type=typeof(ItemSearch) param-Search=Model.Search render-mode=Server />
在我的首页上:
Information: Normalizing '_blazor' to 'https://localhost:7216/_blazor'.
当我进行搜索时:
https://localhost:7216/Search/_blazor/initializers 404