小编Ada*_*ars的帖子

ASP .NET vNext MVC没有传递到下一个管道?

我对ASP .NET vNext有一个麻烦的问题; 更具体地说,MVC.

这是我的Startup.cs文件的简化版本:

public void ConfigureServices(IServiceCollection services)
{

    // Add MVC services to the services container.
    services.AddMvc();
    services.AddScoped<Foo>();

}

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory)
{

    app.Use(async (context, next) =>
    {
        await context.RequestServices.GetService<Foo>().Initialize(context);
        await next();
    });
    // Add MVC to the request pipeline.
    app.UseMvc(routes =>
    {
        routes.MapRoute(
            name: "default",
            template: "{controller}/{action}/{id?}",
            defaults: new { controller = "Home", action = "Index" });
    });

    // Time to save the cookie.
    app.Use((context, next) =>
    {
        context.RequestServices.GetService<Foo>().SaveCookie();
        return next();
    }); …
Run Code Online (Sandbox Code Playgroud)

asp.net-core

5
推荐指数
1
解决办法
1102
查看次数

标签 统计

asp.net-core ×1