سؤال

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?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top