gpt4 book ai didi

c# - index.html 未显示为默认页面

转载 作者:IT王子 更新时间:2023-10-29 03:54:33 26 4
gpt4 key购买 nike

我在 .NET Core 中创建了一个 empty Web 应用程序,在 wwwroot 中我有 index.html 默认情况下未加载页面,它仅在我明确调用它时加载。

这是我的 project.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();

app.UseStaticFiles(); 之前,在 Configure 方法中。

参见 documentation了解更多详情。

关于c# - index.html 未显示为默认页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35777631/

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