RouteExistingFiles 不再是 asp.net 5 的一部分了吗?
Is RouteExistingFiles no longer part of asp.net 5?
我搜索 github 来源和 http://docs.asp.net/en/latest,但找不到 RouteExistingFiles 的任何文档。我试过将它添加到 routes.RouteExistingFiles
,但这不会编译。 是否已删除或重新考虑此选项?可以从 StartUp 访问吗?
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services
.AddMvc()
.AddRouting();
}
public void Configure(IApplicationBuilder app)
{
StaticFileOptions option = new StaticFileOptions();
FileExtensionContentTypeProvider contentTypeProvider = (FileExtensionContentTypeProvider) option.ContentTypeProvider;
contentTypeProvider.Mappings.Add(".yqs", "text/plain");
app
.UseStaticFiles(option)
.UseDefaultFiles()
.UseFileServer()
.UseMvc(routes =>
{
routes.MapRoute(
"YQ Controller",
"{*src}",
new { controller = "YQFile", action = "OnDemand" },
new { src = @"(.*?)\.(yqs)" }
);
});
}
}
虽然我找不到任何文档,但似乎 asp.net 中没有此选项 5. 现在, StartUp.Configure()
中的路由和其他配置似乎优先于继续配置.因此,在链中将 app.UseMvc()
配置向前移动将使路由优先于 app.UseStaticFiles()
。
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services
.AddMvc()
.AddRouting();
}
public void Configure(IApplicationBuilder app)
{
app
.UseMvc(routes =>
{
routes.MapRoute(
"YQ Controller",
"{*src}",
new { controller = "YQFile", action = "OnDemand" },
new { src = @"(.*?)\.(yqs)" }
);
})
.UseStaticFiles()
.UseDefaultFiles()
.UseFileServer();
}
}
我搜索 github 来源和 http://docs.asp.net/en/latest,但找不到 RouteExistingFiles 的任何文档。我试过将它添加到 routes.RouteExistingFiles
,但这不会编译。 是否已删除或重新考虑此选项?可以从 StartUp 访问吗?
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services
.AddMvc()
.AddRouting();
}
public void Configure(IApplicationBuilder app)
{
StaticFileOptions option = new StaticFileOptions();
FileExtensionContentTypeProvider contentTypeProvider = (FileExtensionContentTypeProvider) option.ContentTypeProvider;
contentTypeProvider.Mappings.Add(".yqs", "text/plain");
app
.UseStaticFiles(option)
.UseDefaultFiles()
.UseFileServer()
.UseMvc(routes =>
{
routes.MapRoute(
"YQ Controller",
"{*src}",
new { controller = "YQFile", action = "OnDemand" },
new { src = @"(.*?)\.(yqs)" }
);
});
}
}
虽然我找不到任何文档,但似乎 asp.net 中没有此选项 5. 现在, StartUp.Configure()
中的路由和其他配置似乎优先于继续配置.因此,在链中将 app.UseMvc()
配置向前移动将使路由优先于 app.UseStaticFiles()
。
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services
.AddMvc()
.AddRouting();
}
public void Configure(IApplicationBuilder app)
{
app
.UseMvc(routes =>
{
routes.MapRoute(
"YQ Controller",
"{*src}",
new { controller = "YQFile", action = "OnDemand" },
new { src = @"(.*?)\.(yqs)" }
);
})
.UseStaticFiles()
.UseDefaultFiles()
.UseFileServer();
}
}