ASP.NET WebForms App with OpenId Connect and Azure AD Connect

ASP.NET WebForms App with OpenId Connect and Azure AD Connect

  1. ASP.NET WebForms App with OpenId Connect and Azure AD Connect
  2. Create ASP.Net Web Form application. Configure application to run on "https"
  3. Install NuGet Package
    1. Install-Package Microsoft.Owin.Security.OpenIdConnect -Pre
    2. Install-Package Microsoft.Owin.Security.Cookies –Pre
    3. Install-Package Microsoft.Owin.Host.SystemWeb –Pre
  4. Register application on Azure
  5. Add initialization code, reference. Ensure to have following namespace added in Startup.Auth.cs under App_Start folder. using Microsoft.Owin.Security; using Microsoft.Owin.Security.Cookies; using Microsoft.Owin.Security.OpenIdConnect; using Owin;
  6. Change ConfigureAuth method of Startup.Auth.cs with following code app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType); app.UseCookieAuthentication(new CookieAuthenticationOptions()); app.UseOpenIdConnectAuthentication( new OpenIdConnectAuthenticationOptions { ClientId = "1d0d7532-fdfe-4152-b283-d3e38ab70d1c", Authority = "https://login.windows.net/44cc3e29-963c-4dce-b794-f2137647b0d8" });


Post a Comment

Previous Post Next Post

Gadgets