Skip to content

Instantly share code, notes, and snippets.

@ms-willfid
ms-willfid / AspNetCore_Auth_OnAuthenticationFailed.cs
Last active August 28, 2019 19:16
Asp.Net Core OnAuthenticationFailed
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// ...
});
services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
.AddAzureAD(options => Configuration.Bind("AzureAd", options));
@ms-willfid
ms-willfid / AspNet_OWIN_OnAuthenticationFailed.cs
Last active March 7, 2023 18:06
Asp.Net OWIN OnAuthenticationFailed
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ResponseType = OpenIdConnectResponseType.CodeIdToken,