Changing context.Properties.RedirectUri in OnTokenValidated event causes correlation failed error

Hey all,
Ours is an ASP.Net core based web application.
We are trying to redirect the user to a different page on successful authentication from the one they had requested, based on certain conditions.
For e.g. if the user’s preferred language is French we try to redirect them to the French landing page instead of the default English page. To achieve this we update the context.Properties.RedirectUri in the OnTokenValidated event. This part works fine and the user is taken to appropriate page post authentication, but once they logout and try to log back in a “Correlation failed” exception is thrown and the user cannot get to any page.


Hi @utopkar ,

ASPNET Core MVC template by default includes this in Startup.cs → ConfigureServices:

services.Configure<CookiePolicyOptions>(options =>
    // This lambda determines whether user consent for non-essential cookies is needed for a given request.
    options.CheckConsentNeeded = context => true;
    options.MinimumSameSitePolicy = SameSiteMode.None;

And this in Startup.cs → Configure:


You need to have both removed or both included, otherwise you will get the correlation error.

See this dev forum question for reference:

1 Like

@Regis Thanks for the response.
app.UseCookiePolicy() was missing indeed but that doesn’t resolve the correlation failed issue for me.
The workaround that works for this is to add OnRemoteFailure and handle this exception.
The moment I remove the OnRemoteFailure event the issue comes back.