Can we have normal login and azure ad sso login in asp.net mvc?

586 views Asked by At

I have tried having a azure sso login in my existing application using the following link (https://learn.microsoft.com/en-us/azure/active-directory/develop/web-app-quickstart?pivots=devlang-aspnet).

When i implemet it the normal login was not working. Since the cookie authentication used by default on startup.cs cause the following issue.

Can anyone let me know if this is possible in asp.net mvc?.

I have reviewed all but i doesn't have any proper documentation or solution to fix this on asp.net mvc. Since all solution includes asp.net core.

Could someone help me out on this?

i have tried replacing the usecookieauthentication which was generated by default with the usecookieauthentication which was given in the microsoft azure sso documentation.

i replaced

app.UseCookieAuthentication(new CookieAuthenticationOptions());

with

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
   AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
   LoginPath = new PathString("/Account/Login"),
   Provider = new CookieAuthenticationProvider
   {
     OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
     validateInterval: TimeSpan.FromMinutes(30),
     regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)),
     OnResponseSignIn = context =>
     {
       context.Properties.IsPersistent = false;
       context.Properties.AllowRefresh = true;
       context.Properties.ExpiresUtc = DateTimeOffset.UtcNow.AddMinutes(timeoutInMinutes);
     }
   },
   SlidingExpiration = true
});

1

There are 1 answers

2
Rajesh  Mopati On

Yes, we can do normal login and azure ad sso login in asp Dot net mvc Follow the below steps to achieve this Create an MVC App with Microsoft Identity Platform Authentication enter image description here Select the dependency services enter image description here

Able to logon with SSO enter image description here ADO Login enter image description here Normal Login: For normal login users need to choose another account as shown in the below screenshot and have to enter the credentials enter image description here