문제

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?

도움이 되었습니까?

해결책

public class VerificationAttribute : ActionFilterAttribute
{

    public VerificationAttribute ()
    {
     }

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


    }

다른 팁

Ignore, think I miss read your question

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top