索引.html不显示为默认页面
本文关键字:默认 显示 html 索引 | 更新日期: 2023-09-27 18:37:10
我在 .NET Core 中创建了一个空的 Web 应用程序,wwwroot
我有索引.html它不会作为默认页面加载,它仅在我显式调用它时才加载。
这是我的项目.json
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
这是我的创业公司:
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app)
{
app.UseStaticFiles();
}
// Entry point for the application.
public static void Main(string[] args) => WebApplication.Run<Startup>(args);
}
你必须添加
app.UseDefaultFiles();
在Configure
方法app.UseStaticFiles();
之前。
有关更多详细信息,请参阅文档。
另一种方法是编辑您的 web.config 文件。在那里添加新规则,满足您的需求。