RouteExistingFiles不再是asp.net 5的一部分吗?

时间:2015-05-05 04:49:38

标签: c# asp.net-core

我搜索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)" }
                );
            });
    }
}

1 个答案:

答案 0 :(得分:1)

虽然我找不到任何文档,但似乎这个选项不在asp.net 5中。现在,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(); } }

$('body').on('click', '.douglascalhoun',function() {
      $("div").slideToggle();
      $("div.douglascalhoun").slideDown();
    });