title: Cannot sign out the OpenIdConnect authentication of identityserver4 on ASP.NET Core 2 application
body: <p>My Identity Server is using identityserver4 framework (<a href="http://localhost:9000" rel="noreferrer">http://localhost:9000</a>). And I register the client on Identity Server as below.</p>
  
  <pre><code>clients.Add(
       new Client
       {
           ClientId = "customer.api",
           ClientName = "Customer services",
           AllowedGrantTypes = GrantTypes.HybridAndClientCredentials,
           RequireConsent = false,
           AllowAccessTokensViaBrowser = true,
  
           RedirectUris = { "http://localhost:60001/signin-oidc" },
           PostLogoutRedirectUris = { "http://localhost:60001/signout-callback-oidc" },
           ClientSecrets = new List&lt;Secret&gt;
           {
               new Secret("testsecret".Sha256())
           },
           AllowedScopes = new List&lt;string&gt;
           {
               IdentityServerConstants.StandardScopes.OpenId,
               IdentityServerConstants.StandardScopes.Profile,
               IdentityServerConstants.StandardScopes.Email,
               IdentityServerConstants.StandardScopes.OfflineAccess,
               "customerprivatelinesvn.api",                        
           },
           AllowOfflineAccess = true,
           AlwaysIncludeUserClaimsInIdToken = true,
           AllowedCorsOrigins = { "http://localhost:60001" }
       });  
  </code></pre>
  
  <p>Here is the authentication on my client app (<a href="http://localhost:60001" rel="noreferrer">http://localhost:60001</a>).</p>
  
  <pre><code>private void AddAuthentication(IServiceCollection services)
  {
      JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
  
      services.AddAuthentication(options =&gt;
      {
          options.DefaultAuthenticateScheme = "Cookies";
          options.DefaultChallengeScheme = "oidc";       
      })
      .AddCookie()
      .AddOpenIdConnect("oidc", options =&gt;
      {
          Configuration.GetSection("OpenIdConnect").Bind(options);        
      });    
  }    
  
  "OpenIdConnect": {
      "SignInScheme": "Cookies",
      "Authority": "http://localhost:9000/",
      "RequireHttpsMetadata": false,
      "ClientId": "customer.api",
      "ClientSecret": "testsecret",
      "Scope": [ "customerprivatelinesvn.api", "offline_access" ],
      "CallbackPath": "/signin-oidc",
      "ResponseType": "code id_token token",
      "GetClaimsFromUserInfoEndpoint": true,
      "SaveTokens": true
    }
  </code></pre>
  
  <p><strong>HomeController of client app</strong></p>
  
  <pre><code>[Authorize]
  public class HomeController : Controller
  {
      public IActionResult Index()
      {
          return View();
      }    
  }
  </code></pre>
  
  <p>Here are the Cookies of client app after user logs in.
  <a href="https://i.stack.imgur.com/9ikeM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9ikeM.png" alt="enter image description here"></a></p>
  
  <p>I try to implement the signout action as below</p>
  
  <pre><code>public class AccountController : Controller
  {
      public async Task&lt;IActionResult&gt; Signout()
      {
          await HttpContext.SignOutAsync("Cookies");
          await HttpContext.SignOutAsync("oidc");
  
          return RedirectToAction("Index", "Home");                  
      }
  }
  </code></pre>
  
  <p>But when user signs out, it doesn't call the endsession endpoint of identity server. I look at the traffic of fiddler, there is no request to identity server.</p>
  
  <p><a href="https://i.stack.imgur.com/OmEYI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/OmEYI.png" alt="enter image description here"></a></p>
  
  <p>My expectation is when user signs out, it will call endsession endpoint of identity server and redirect to logout link of identity server as below.</p>
  
  <p><a href="https://i.stack.imgur.com/B0Wrt.png" rel="noreferrer"><img src="https://i.stack.imgur.com/B0Wrt.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/8T2jc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8T2jc.png" alt="enter image description here"></a></p>
  
  <p>We can do this easily on MVC application by calling OwinContext signout</p>
  
  <pre><code>private void LogoutOwin(IOwinContext context)
          {
              context.Authentication.SignOut();
          }
  </code></pre>
  
  <p>But the signout method doesn't work anymore on ASP.NET Core 2.</p>
  
  <p>Note: I'm calling the signout action from an AJAX post because my client app is angular 5 app.</p>
  
  <p>Does anyone know how to implement the signout correctly on ASP.NET Core 2? </p>
  
  <p>Thank you very much.</p>
  
  <p>Regards,</p>
  
  <p>Kevin</p>