0

I'm overriding OnResultExecuted checking a condition: if it is true then redirect.

I'm struggling on figure out how to make redirect working. I have to launch redirect only on result executed because I have to check if the http response is 404 (if so redirect to a search page ... etc.)

Here's my code

protected override void OnResultExecuted(ResultExecutedContext filterContext)
{
    [...]
    filterContext.Result = new RedirectResult(redirectUrl);
    base.OnResultExecuted(filterContext);
}

Any suggestions?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Massimo Variolo
  • 4,669
  • 6
  • 38
  • 64

1 Answers1

0

You can try the following:

protected override void OnResultExecuted(ResultExecutedContext filterContext)
{
    [...]
    filterContext.HttpContext.Response.Redirect(redirectUrl);
}
Ehsan Sajjad
  • 61,834
  • 16
  • 105
  • 160