Search code examples
c#asp.net-mvcaction-filter

How to prevent custom filters twice calls?


I have a custom authorize filter that called two times.

public sealed class SamaAuthorizeAttribute : AuthorizeAttribute
{
    public override void OnAuthorization(AuthorizationContext filterContext)
    {
        //some code
        base.OnAuthorization(filterContext);
    }

    protected override bool AuthorizeCore(HttpContextBase httpContext)
    {
        //some logic code here
        return true;
    }
}

I just add it globally and not set it for any action. i search it in all web but can not find good answer. i used StructureMap library for dependency injection; but i don't have any ioc filter registration. even i used "AllowMultiple = false" but not worked for me.


Solution

  • the problem was an ajax call in my scripts.