asp.net core 2.2 with Azure b2c changing the redirect_uri query string parameter RRS feed

  • Question

  • User1997618745 posted

    Dear All, 

    We have have an application configured with Azure b2c. 

    When user clicks the login link asp.net core application constructs the b2c login url from the appsetting.json configuration values and redirects. before it redirects I wanted to change the redirect_uri query string parameter to something else.. 

    can you guys please advice how can we do this ? 

    Thursday, July 25, 2019 1:33 AM


  • User711641945 posted

    Hi Selvakumar,

    You could not change the redirect_uri since the redirect_uri in the asp.net core 2.2 and azure application portal should match the same.

    If you only change the rediect_uri at asp.net core, it will fail to authenticate.

    For another way, you could attach your query string in the state like below: 

    services.Configure<OpenIdConnectOptions>(AzureADB2CDefaults.AuthenticationScheme, options =>
            options.Events = new OpenIdConnectEvents
                OnRedirectToIdentityProvider = async n =>
                    //set your query stirng here to state
                    n.ProtocolMessage.State = n.HttpContext.Request.Path.Value.ToString();
                OnTokenValidated = ctx =>
                    //get state from response
                    var url = ctx.ProtocolMessage.GetParameter("state");                        
                    return Task.CompletedTask;

    Best Regards,


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 25, 2019 9:31 AM