Подтвердить что ты не робот

Index.html не отображается как страница по умолчанию

Я создал пустое веб-приложение в .NET Core, в 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);
}
4b9b3361

Ответ 1

Вы должны добавить

app.UseDefaultFiles();

до app.UseStaticFiles(); в Configure.

Подробнее см. .

Ответ 2

Другой способ сделать это - отредактировать файл web.config. Добавьте туда новые правила, соответствующие вашим потребностям.