I'm trying to setup a new web application and I would to load the index.html (wwwroot folder) at startup.
In ASP.NET 5 Beta 6 this can be simply done only with app.UseStaticFiles() call inside Configure method even if MVC is configured.
Now, in Beta 7 (with Web Tools 2015 Beta7 installed), this doesn't work anymore :( I found on many articles that I'm supposed to add this call too:
app.UseDefaultFiles(new DefaultFilesOptions
{
DefaultFileNames = new [] { "index.html" }
});
But even with that the index.html is not served by the framework.
Here is my 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();
}
}
Someone knows how to solve this problem?
It worked before because IIS fall through was opted in by default, but now you have to opt in explicitly as mentioned in the breaking changes in the announcements repo