Matt W
Matt W

Reputation: 12423

How to redirect during OnTicketReceived

In our OIDC flow I have this method...

    options.Events.OnTicketReceived = async context =>
    {
      ...
        (bool doRedirect, string destUrl) = redirectHelper.ProcessRedirectionRules(user);
        if (doRedirect)
        {
          context.Response.Redirect(destUrl);
          return;
        }
      
      ...
    };

Unfortunately, though I really need to redirect the user to a destination URL, the context.Response.Redirect(destUrl); does not perform a redirection at all.

Am I attempting to redirect in the wrong place or in the wrong way? How should this be done?

Upvotes: 0

Views: 1145

Answers (1)

Josh
Josh

Reputation: 299

I think you're missing this:

if (doRedirect)
{
  context.Response.Redirect(destUrl);
  context.HandleResponse();
  return;
}

Summary: Discontinue all processing for this request and return to the client. The caller is responsible for generating the full response.

Upvotes: 2

Related Questions