raj raj

raj raj

  • 1.1k
  • 256
  • 18.3k

microsoft inbuilt azuread authentication in asp.net mvc getting error

Jun 30 2023 9:54 AM

I am using microsoft inbuilt authorization in asp.net mvc.

I am using below call in startup.auth.cs. I am getting prompt in mobile for authorization after allowing it is not redirecting in default page.

private static string clientId = ConfigurationManager.AppSettings["ida:ClientId"];
        private static string aadInstance = EnsureTrailingSlash(ConfigurationManager.AppSettings["ida:AADInstance"]);
        private static string tenantId = ConfigurationManager.AppSettings["ida:TenantId"];
        private static string postLogoutRedirectUri = ConfigurationManager.AppSettings["ida:PostLogoutRedirectUri"];
        private static string authority = aadInstance + tenantId;
        
        public void ConfigureAuth(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

            app.UseCookieAuthentication(new CookieAuthenticationOptions());

            app.UseOpenIdConnectAuthentication(
                new OpenIdConnectAuthenticationOptions
                {
                    ClientId = clientId,
                    Authority = authority,                    
                    PostLogoutRedirectUri = postLogoutRedirectUri
                });
        }


Answers (2)