小编War*_*rog的帖子

aspnet-core 中的条件中间件在 asp.net core 1.1 中不起作用

我按照这篇文章在我们的项目中实现了条件中​​间件,它运行得很好。但当我们将项目从 .netcore 1.0 升级到 .netcore 1.1 时,它不起作用。

我在我的启动中编写了以下代码。

Func<HttpContext, bool> isApiRequest = (HttpContext context) => context.Request.Path.ToString().StartsWith("/api/");

JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

//For MVC not API
app.UseWhen(context => !isApiRequest(context), appBuilder =>
{
    app.UseCookieAuthentication(new CookieAuthenticationOptions
    {
        AuthenticationScheme = "Cookies",
        AutomaticAuthenticate = true
    });

    app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
    {
        AuthenticationScheme = "oidc",
        SignInScheme = "Cookies",
        AutomaticChallenge = true,


        Authority = authority,
        RequireHttpsMetadata = false,

        ClientId = "sampleClient",
        //ClientSecret = "secret",

        Scope = { "openid" , "profile" },

        ResponseType = "id_token token",//"code id_token",                        

        SaveTokens = true
    }); …
Run Code Online (Sandbox Code Playgroud)

c# asp.net .net-core asp.net-core identityserver4

3
推荐指数
1
解决办法
4647
查看次数

标签 统计

.net-core ×1

asp.net ×1

asp.net-core ×1

c# ×1

identityserver4 ×1