asp.net - 如何在 C# 中使用 ASP.NET Core 5 在每条路由上提供静态文件夹?
问题描述
现在我用
app.UseDefaultFiles();
app.UseStaticFiles();
和UseWebRoot("./public");
/
在路线上提供公用文件夹。
其中包含
index.html
bundle.js
如果我使用该/nested
路由,它将nested
在我的文件服务器中查找文件夹。
如果我在每条路线上使用app.UseSpa()
或app.UseSpaStaticFiles();
使用,return File("index.html", "text/html");
它将把公用文件夹中的每个文件作为index.html
.
如何配置以便我可以在每条路由上为同一个公用文件夹提供默认文件?
例如,如果我要求/nested/route
我仍想提供将在该文件夹public
中呈现index.html
的文件夹,而不是public/nested/route
文件夹。
解决方案
推荐阅读
- javascript - 映射 json 并在 React 中添加图像
- java - Spring 存储库将 HQL 发送到数据库服务器
- java - 如何转换 ArrayList
到包含十进制值的双[]? - javascript - 查看每个调用旁边的 javascript 代码的执行时间
- azure - Azure CDN 终结点中的裸域具有错误的 HTTPS 证书名称
- php - 根据另一个输入值(0-100 之间的数字)将 DIV ID(字母)传递/回显到输入值
- python - 在没有scipy的python中将COO转换为CSR格式
- php - HTML 显示为文本
- python - 如何从列表中获取方括号中的唯一值
- html - 可以
在没有父级的情况下使用