admin管理员组文章数量:1125333
I have a Blazor Hosted WebAssembly which means that I have three projects, the Client, the Server and the Shared. The inter-communication happens with web-apis.
On the Client, into index.html I have the following:
<base href="/app/" />
On the Client, into Clientn.csproj I have the following:
<StaticWebAssetBasePath>app</StaticWebAssetBasePath>
On the Server, into program.cs I have the following:
app.UseBlazorFrameworkFiles("/app");
app.UseStaticFiles();
app.UsePathBase("/app");
app.MapFallbackToFile("/app" + "/" + "index.html");
With those settings the application starts and loading but it fails to load two packages:
Blazored.Modal
Blazored.TextEditor
These two packages are trying to find resources into /app/_content but the resources are not there.
When the application is running without a subpath it works normally
Any ideas?
I have a Blazor Hosted WebAssembly which means that I have three projects, the Client, the Server and the Shared. The inter-communication happens with web-apis.
On the Client, into index.html I have the following:
<base href="/app/" />
On the Client, into Clientn.csproj I have the following:
<StaticWebAssetBasePath>app</StaticWebAssetBasePath>
On the Server, into program.cs I have the following:
app.UseBlazorFrameworkFiles("/app");
app.UseStaticFiles();
app.UsePathBase("/app");
app.MapFallbackToFile("/app" + "/" + "index.html");
With those settings the application starts and loading but it fails to load two packages:
Blazored.Modal
Blazored.TextEditor
These two packages are trying to find resources into /app/_content but the resources are not there.
When the application is running without a subpath it works normally
Any ideas?
Share Improve this question asked 2 days ago Stavros KoureasStavros Koureas 1,4721 gold badge18 silver badges45 bronze badges1 Answer
Reset to default 0app.UsePathBase("/app"); would consider https://localhost:port/app
as the base path,you have to reach your static files with https:localhost:port/app/app/_content/Blazored.Modal/BlazoredModal.razor.js
A minimal sample that works well on myside:
Server project Program.cs:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllersWithViews();
builder.Services.AddRazorPages();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseWebAssemblyDebugging();
}
else
{
// 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.MapWhen(ctx => ctx.Request.Path.StartsWithSegments("/app"), app1 =>
{
app1.UseBlazorFrameworkFiles("/app");
app1.UseRouting();
app1.UseEndpoints(endpoints =>
{
endpoints.MapFallbackToFile("/app/{*path:nonfile}", "/app/index.html");
});
});
app.Run();
.Client Project csproj:
<StaticWebAssetBasePath>app</StaticWebAssetBasePath>
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>BlazoreModalApp</title>
<base href="/app/" />
<link href="css/app.css" rel="stylesheet" />
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/quill.snow.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/quill.bubble.css" rel="stylesheet">
<link href="BlazoreModalApp.Client.styles.css" rel="stylesheet">
<!-- If you add any scoped CSS files, uncomment the following to load them
<link href="BlazoreModalApp.Client.styles.css" rel="stylesheet" /> -->
</head>
<body>
<div id="app">Loading...</div>
<div id="blazor-error-ui">
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss">
本文标签:
版权声明:本文标题:http redirect - Blazor Hosted WebAssembly subpath (base-href) not working with some nuget packages - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人,
转载请联系作者并注明出处:http://www.betaflare.com/web/1736656415a1946266.html,
本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论