gpt4 book ai didi

c# - ASP.NET Core - 提供静态文件

转载 作者:太空狗 更新时间:2023-10-30 01:00:11 24 4
gpt4 key购买 nike

<分区>

我正在关注这个文档,但我被卡住了: 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> 转到该页面?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com