【发布时间】:2022-01-01 21:42:57
【问题描述】:
我正在使用 .NET 6 中的 web api。一切都按预期工作。但是,我正在尝试在 wwwroot 下加载一个简单的 HTML/CSS 登录页面。
我想补充一点,我从来没有遇到过这个问题,使用 .NET 3.0 或 .NET 5 具有类似的配置。
我有我的 Program.cs
app.UseSwagger();
app.UseSwaggerUI();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAuthorization();
app.MapControllers();
app.Run();
现在,如果我要手动访问 localhost/index.html,我会在本地以及部署在 azure Web 应用程序上时获得登录页面。
但是,如果到达 localhost(或已部署的 Web 应用程序),index.html 将不会像在旧版本的 .NET 中那样加载。
是我遗漏了什么还是这像是一个错误?
注意:我看过另一个类似的问题。我想,不一样。
【问题讨论】:
-
听起来你需要set the default document 来申请你的应用程序。
-
@RichardDeeming 做到了!谢谢。
标签: c# asp.net-core static-files .net-6.0 asp.net-core-6.0