locked
ASP.NET 4.5 and OWIN connecting to Azure AD B2C RRS feed

  • Question

  • Please forgive if I am posting this to the wrong group.

    I have been tasked by our company to connect a legacy ASP.NET non-MVC app (VS 2012) running on .NET 4.5 to our Azure AD B2C tenant and enable multi-factor authentication. 

    I have found instruction to create a small ASP.NET web app (not web api), install and include the Microsoft OWIN libraries from Nu Get, and write from scratch a small startup.cs and startup.auth.cs class to handle the OpenID connect authentication when the application is started.  This works fine and is talking to a Azure AD B2C tenant setup under my dev account, and forcing the user to do 2 factor authentication.  The test app is running under IIS express / VS 2012 and is using .NET 4.5 framework like our legacy app.

    Now, I would like to take this same work and roll it into the existing ASP.NET application.  For dev purposes, the legacy app is currently running locally on IIS (not express) on my machine.  When I inititiate the app, through trial and error I know the startup.cs class and the UseOpenIdConnectAuthenitication() code is being executed, but the site is not redirecting to the Azure login page like the former test app.

    Is there anything I can check to see if any attempt is being made to connect to Azure?  Are there any issues with running the app locally on IIS and connecting to Azure (e.g. firewall)?  This is an entirely new area for me and I'm just need a little direction if someone has had similar experiences.

    Thanks,

    Bruce

    UseOpenIdConnectAuthentication

    Friday, May 19, 2017 9:24 PM

Answers

  • We figured this out.   Needed this code in our default.aspx

            protected void Page_Load(object sender, EventArgs e)
            {
                if (!Request.IsAuthenticated)
                {
                    HttpContext.Current.GetOwinContext().Authentication.Challenge(
                        new AuthenticationProperties { RedirectUri = "/" },
                        OpenIdConnectAuthenticationDefaults.AuthenticationType);
                }
            }

    • Marked as answer by bmcdougald Monday, May 22, 2017 4:51 PM
    Monday, May 22, 2017 4:51 PM

All replies

  • Suggest you to create a Technical Support Ticket on this, as our engineers would need to work with you on the issue and would also require sensitive information like the subscription and tenant details.

    ---------------------------------------------------------------------------------------------------
    Do click on "Mark as Answer" on the post that helps you, this can be beneficial to other community members.


    Saturday, May 20, 2017 3:30 PM
  • We figured this out.   Needed this code in our default.aspx

            protected void Page_Load(object sender, EventArgs e)
            {
                if (!Request.IsAuthenticated)
                {
                    HttpContext.Current.GetOwinContext().Authentication.Challenge(
                        new AuthenticationProperties { RedirectUri = "/" },
                        OpenIdConnectAuthenticationDefaults.AuthenticationType);
                }
            }

    • Marked as answer by bmcdougald Monday, May 22, 2017 4:51 PM
    Monday, May 22, 2017 4:51 PM
  • We are glad to know that your issue has been resolved.

    --------------------------------------------------------------------------------------------------- 
    Do click on "Mark as Answer" on the post that helps you, this can be beneficial to other community members.

    • Edited by vijisankar Tuesday, May 23, 2017 7:07 PM
    Tuesday, May 23, 2017 10:31 AM