0

I have a custom authorize filter that is on the controller and on some of the actions. The ones on the actions have parameters where the controller filter does not. So, I want the controller filter to apply only to the ones that do not have that same filter with parameters. I tried putting it on both places but the filter is called twice

    [CustomAuthorize]
    public class Controller
    {

        public ActionResult Index()
        {
            return View();
        }
        [CustomAuthorize(param1 ="123")]
        public ActionResult Index2()
        {
            return View();
        }

In the snippet above it calls customauthorize twice once with no parameters and second with parameters.

How do i prevent the first customauthorize if the action already has a customauthorize?

imGreg
  • 900
  • 9
  • 24

1 Answers1

0

Idea of attributes on controller is to apply this for each action. So there are no possibility to run only action's attribute. (there is if you remove class' ones)

In this SO answer it's quite well described when to use it.

Community
  • 1
  • 1
Mateusz Rogulski
  • 7,357
  • 7
  • 44
  • 62