我正在关注此文档,但我遇到了困难:https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files
考虑我的目录结构:
wwwroot
dist
index.html
在我的创业课程中,我有:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "dist"))
});
}
当我启动应用程序时,我看不到我的 index.html 页面,但如果我导航到<host>/dist/index.html
我如何配置它以便 ASP.NET 自动将我带到该页面<host>
?
您需要创建中间件或 URL 重写来为您完成这项工作。 ASP.NET Core 并不是最智能的,它不会手动为您做一些事情。
你也应该做WebHostBuillder.UseWebRoot(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "dist"))
在你的Program.cs
file.
另外,这看起来像是重复的this. https://stackoverflow.com/questions/45316230/net-core-changing-the-location-where-my-default-index-html-file-is
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)