Question

I have an attribute on my Controller

[ABC]  
MyController

The Attribute checks something but I only want to check once per page.

public class ABCAttribute : ActionFilterAttribute
{
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        ////Do some check
    }

The OnActionExecuting fires for every element on the page. Partials etc.

How do I check to see if the filterContext is the main page and not a child resource on the page?

Was it helpful?

Solution

public class VerificationAttribute : ActionFilterAttribute
{

    public VerificationAttribute ()
    {
     }

    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        //We don't care about children/partials
        if (filterContext.IsChildAction)
            return;


    }

OTHER TIPS

Ignore, think I miss read your question

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top