Orchard CMS continues executing request after permanent redirect from IActionFilter

隐身守侯 提交于 2020-01-05 10:26:10

问题


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:


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.



来源:https://stackoverflow.com/questions/16561962/orchard-cms-continues-executing-request-after-permanent-redirect-from-iactionfil

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!