Asp.Net core JWTBearer OnAuthenticationFailed redirect issue RRS feed

  • Question

  • Hi,

    I have created 2 microservices(docker containerized). Now if some controller action is not authorized, I want it to redirect to login page in login microservice. Currently its giving 401 - UnAuthorized error.

    I tried to override OnAuthenticationFailed event, but debugger is never reaching there. I hope something going wrong in middleware pipeline. Please help.

    Below is the code in StartUp.cs file of authorizing microservice:

                            var identityUrl = "";
    services.AddAuthentication(options => {
    options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
    options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
    }).AddJwtBearer(options => {
    options.Authority = identityUrl;
    options.RequireHttpsMetadata = false;
    options.Audience = "application";

    Wednesday, June 5, 2019 8:43 PM

All replies

  • Hi rajeev16mca2k5,

    Thank you for posting here.

    For your question is more related to ASP.NET, you could post a new thread in ASP.NET forum.


    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, June 6, 2019 5:23 AM