1

We have a website that uses Orchard CMS and we've written a "RedirectFilter" to do permanent redirects on legacy URLs (aliases that don't match the AutoroutePart pattern for the relevant Content Item).

The filter implements IActionFilter and inherits FilterProvider. It works fine and when it does a redirect it calls the following method in OnActionExecuting:

filterContext.HttpContext.Response.RedirectPermanent(targetPath, true);

According to the documentation the second parameter suggests that a ThreadAbortException will be thrown to abort the current request. However, the request is still processed for the legacy URL, I know this because the Part Drivers still execute for both the legacy and new URLs.

How can I abort the request from the filter without Orchard continuing to execute it?

1 Answer 1

1

Just worked this out. Need to use this instead:

filterContext.Result = new RedirectResult(targetPath, true);

I'm guessing you can't call RedirectPermenant inside a filter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.