Secure Your ASP.NET Web Forms Application with OpenID Connect and Okta

Richard Corkery

I, and a few others, had an issue with the logout process. I was able to get this resolved by adding the code shown below in Startup.cs. The new code is placed under the n.AuthenticationTicket.Identity.AddClaims(claims); line shown above in the original post. I include that line to identify where the new code should be placed. The new code starts with: RedirectToIdentityProvider.

I hope this helps someone else since I spent hours trying to figure it out.

n.AuthenticationTicket.Identity.AddClaims(claims);
},
RedirectToIdentityProvider = n =>
{
// If signing out, add the id_token_hint
if (n.ProtocolMessage.RequestType == OpenIdConnectRequestType.Logout)
{
var idTokenClaim = n.OwinContext.Authentication.User.FindFirst(“id_token”);

if (idTokenClaim != null)
{
n.ProtocolMessage.IdTokenHint = idTokenClaim.Value;
}

}

return Task.CompletedTask;
}