0

I have a solution where Forms Authentication in place, now I am trying to integrate azure along with Forms Authentication so that when they choose Login using AD it will navigate to portal and get the response. In the POC I developed it works fine where it has no Forms Authentication, but when I integrate with the actual application it is not getting navigated to portal

private void AzureLogin() {
    HttpContext.Current.GetOwinContext().Authentication.Challenge(
    new AuthenticationProperties { RedirectUri = "/" },
    new MailAddress(txtUsername.Text).Host);
}

It is always redirecting to default page instead of navigating. I have commented the FormsAuthentication section in web.config but still it is navigating to login page

Developer
  • 8,390
  • 41
  • 129
  • 238
  • Could you please refer this similar threads in SO https://stackoverflow.com/questions/38999304/mixing-azure-ad-authentication-with-forms-authentication , https://stackoverflow.com/questions/45030785/forms-and-azure-ad-authentication , and https://forums.asp.net/t/2169041.aspx?Forms+authentication+with+AD+ – AjayKumarGhose Sep 15 '21 at 09:51

1 Answers1

0

Your application is redirecting you to the default page instead of navigating due to this code:

new AuthenticationProperties { RedirectUri = "/" },

Update this line then to new AuthenticationProperties { RedirectUri = "/login"} and this should redirect your application to the login page. By setting this RedirectUri property means you are setting the full path which is used as an HTTP redirect response value.

enter image description here

Learn more about the auth code flow here and here for access tokens.

Rutha
  • 751
  • 3
  • 7
  • `new AuthenticationProperties { RedirectUri = "/" },` This was setup in startup but the problem is with FormsAuthentication so I turned it off then I got this issue https://stackoverflow.com/questions/69192051/idx21323-requirenonce-is-pii-is-hidden-openidconnectprotocolvalidationcont – Developer Sep 15 '21 at 19:31