![](/img/trans.png)
[英]Failed to load resource (CSS,JS and picture files) after updating ASP.NET 5 from Beta6 to Beta7
[英]ASP.NET 5 Beta 7 (Web Tools 2015 Beta7) - wwwroot/index.html not served
我正在嘗試設置一個新的Web應用程序,我會在啟動時加載index.html(wwwroot文件夾)。
在ASP.NET 5 Beta 6中,即使配置了MVC,也只需使用Configure方法內的app.UseStaticFiles()調用即可完成。
現在,在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,但是現在你必須明確選擇公告回購中的重大變化
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.