Redirect to another page in custom request event handler

Quang Lai asked on December 19, 2015 22:49

I'm trying to mimic the Application_BeginRequest in a non-MVC Kentico setup, and have a custom handler module loader with a RequestEvents.Begin.Execute method. Depending on a particular condition, I want to redirect the user, but the Response object is not available (for Response.Redirect(...)). HttpContext is also not available.

The first parameter of the RequestEvents method is a CMS.Base.SimpleHandler, and there's nothing there that seems to fit the bill either. Second parameter is the base EventArgs which doesn't help either.

Correct Answer

Jan Hermann answered on December 21, 2015 09:14


Please use one of following methods:

URLHelper.RedirectPermanent -> for 301 redirects
URLHelper.Redirect -> for 302 redirects

Best regards,
Jan Hermann

0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.