Search code examples
orchardcmsaction-filter

Orchard - How to understand if I'm calling from Admin panel


I need to execute some code everytime I load a page, except if the page belongs to the admin panel. I created an IActionFilter and in the OnActionExecuting method I tried to check for the Controller name, but it isn't an optimal solution because there are a lot of different controllers being called from the dashboard. Is there a more efficient way to recognize if I'm loading a page of the admin panel?


Solution

  • Yes there is

    using Orchard.UI.Admin;
    

    &

    if (AdminFilter.IsApplied(filterContext.RequestContext))
    {
        // This is an admin page, do nothing
        return;
    }