ASP.NET 5 Beta 7 (Web Tools 2015 Beta7) - wwwroot/index.html
本文关键字:Beta7 wwwroot html index 2015 Tools NET Beta Web ASP | 更新日期: 2023-09-27 18:14:55
我正在尝试设置一个新的web应用程序,我会在启动时加载index.html (wwwroot文件夹)。
在ASP。即使配置了MVC,也可以通过app.UseStaticFiles()方法调用来实现。
现在,在Beta7(与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失败是默认选择加入的,但现在你必须显式地选择加入,就像公告中的突破性变化中提到的那样