这个问题已经在这里有一个答案:
我下面这个文档,但我卡住:https://docs.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的核心是不是最聪明的,它是不会为你做手工的东西。
你也应该在你的WebHostBuillder.UseWebRoot(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "dist"))
文件做Program.cs
。
此外,这看起来像this.的副本