Blazor
部署到子目录
环境:
asp.net core
期望访问路径
/balzor/index.html
1、将blazor项目发布文件拷贝到wwwroot的blazor中
2、修改index.html中 base标签 为
<base href="/blazor/" />
3、修改index.html中绝对路径 为带子目录的绝对路径
4、解决部分文件无法访问的问题
修改startup.cs 的 app.UseStaticFiles(); 为下面代码
var provider = new Microsoft.AspNetCore.StaticFiles.FileExtensionContentTypeProvider();
provider.Mappings[".less"] = "application/octet-stream";
provider.Mappings[".dll"] = "application/octet-stream";
provider.Mappings[".blat"] = "application/octet-stream";
provider.Mappings[".dat"] = "application/octet-stream";
app.UseStaticFiles(new StaticFileOptions
{
ContentTypeProvider = provider
});