Azure logon - specify callback url for invalid request

I configured my web application to use Azure Auth login. Everything is working fine, and users can log in if they are not already logged in to Azure.

My problem is that when a user is already logged into Azure of Office 365 and they are browsing my site, they get this error below. I understand what the error means, but I want to know if there is a way to redirect to another URL (on my site) if this problem occurs. Here is the error: enter image description here

This is my startup code to configure OpenId Auth:

app.UseOpenIdConnectAuthentication( new OpenIdConnectAuthenticationOptions { ClientId = Configuration.clientID, Authority = authenticationAuthority, PostLogoutRedirectUri = Configuration.logoutRedirectURL, Notifications = new OpenIdConnectAuthenticationNotifications { AuthenticationFailed = context => { context.HandleResponse(); context.Response.Redirect("/Unauthorised.aspx?message=" + context.Exception.Message); return Task.FromResult(0); } } }); 
+7
openid azure azure-web-sites azure-active-directory
source share

No one has answered this question yet.

See related questions:

51
What is the advantage of using ONLY OpenID authentication on the site?
3
Connect ASP.NET MVC 5 with Azure AD Dynamic
2
Azure Web Application Authentication / Authorization Issue
2
Azure SSO error: AADSTS50020 when prompt = consent and user is an active account
2
Request API for Login Activity Events
one
Azure AD | Login conflict with another Azure account
one
AADSTS70001: Application with identifier 'guid' was not found in the directory
one
How to set domain hint for Azure AD multitasking request?
one
Azure AD with invitation = no shows an invalid request when a user logs in to another tenant
0
New Azure users: You do not have permission to view this directory or page

All Articles