ASP.NET 5 Beta 7(网络工具 2015 Beta7)- wwwroot/index。html 未提供

ASP.NET 5 Beta 7 (Web Tools 2015 Beta7) - wwwroot/index.html not served

我正在尝试设置一个新的 Web 应用程序,我会在启动时加载 index.html(wwwroot 文件夹)。

在 ASP.NET 5 Beta 6 中,即使配置了 MVC,也只能通过 app.UseStaticFiles() 在 Configure 方法中调用来简单地完成此操作。

现在,在 Beta 7(安装了 Web Tools 2015 Beta7)中,这不再有效:​​( 我在许多文章中发现我也应该添加此调用:

app.UseDefaultFiles(new DefaultFilesOptions
{
    DefaultFileNames = new [] { "index.html" }
});

但即便如此,index.html 仍未由框架提供服务。

这是我的 Startup.cs:

public class Startup
{
    public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
    {
        var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
            .AddJsonFile("config.json")
            .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);

        if (env.IsDevelopment())
        {
            builder.AddUserSecrets();
        }
        builder.AddEnvironmentVariables();
        Configuration = builder.Build();
    }

    public void ConfigureServices(IServiceCollection services)
    {
        // Add MVC services to the services container.
        services.AddMvc();
    }

    public async void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        // Add static files to the request pipeline.
        app.UseStaticFiles();

        // Add default files to the request pipeline
        app.UseDefaultFiles(new DefaultFilesOptions
        {
            DefaultFileNames = new [] { "index.html" }
        });

        // Add MVC to the request pipeline.
        app.UseMvc();
    }
}

有人知道如何解决这个问题吗?

它之前是有效的,因为 IIS 失败是默认选择加入的,但现在你必须明确选择加入 as mentioned in the breaking changes in the announcements repo