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
  • 704,970
  • 168
  • 1,303
  • 1,425
Massimo Variolo
  • 4,499
  • 6
  • 37
  • 62

1 Answers1

0

You can try the following:

protected override void OnResultExecuted(ResultExecutedContext filterContext)
{
    [...]
    filterContext.HttpContext.Response.Redirect(redirectUrl);
}
Ehsan Sajjad
  • 60,736
  • 15
  • 100
  • 154