This question is locked. New answers and comments are not allowed.
Hi All,
I'm using the Menu control that's tied to the site map in my project and I'm extending AuthorizeAttribute so I can customize the access based on the logged on user. The class is called CustomAuthorizeAttribute which derives from AuthorizeAttribute and overrides AuthorizeCore, which put the custom security stuff in. Then I use CustomAuthorizeAttribute to decorate each controller's action that corresponds to a menu item.
From my understanding, when the Menu control is building up the menu items, it will notice the presence of CustomAuthorizeAttribute and end up calling AuthorizeCore to determine if each menu item should be visible to the user. This setup was working well for MVC2 but after I upgraded to MVC3 Preview (MVC3 Beta also has the same issue), the menu items won't show up anymore. I even hardcoded the AuthorizeCore to always return "true" but that didn't help.
To look into the issue further, I have set up two test projects (attached) - one using MVC2 and another using MVC3 Preview. CustomAuthorizeAttribute.cs contains the definition of CustomAuthorizeAttribute. And I have the attribute declared on the Index action of TestController. It turns out that for the MVC3 project, AuthorizeCore is not getting called at all. It seems like when I put CustomAuthorizeAttribute on top of TestController.Index() the menu item corresponding to it will just be hidden. Any thoughts on this will be appreciated.
Thanks a lot,
Ben
I'm using the Menu control that's tied to the site map in my project and I'm extending AuthorizeAttribute so I can customize the access based on the logged on user. The class is called CustomAuthorizeAttribute which derives from AuthorizeAttribute and overrides AuthorizeCore, which put the custom security stuff in. Then I use CustomAuthorizeAttribute to decorate each controller's action that corresponds to a menu item.
From my understanding, when the Menu control is building up the menu items, it will notice the presence of CustomAuthorizeAttribute and end up calling AuthorizeCore to determine if each menu item should be visible to the user. This setup was working well for MVC2 but after I upgraded to MVC3 Preview (MVC3 Beta also has the same issue), the menu items won't show up anymore. I even hardcoded the AuthorizeCore to always return "true" but that didn't help.
To look into the issue further, I have set up two test projects (attached) - one using MVC2 and another using MVC3 Preview. CustomAuthorizeAttribute.cs contains the definition of CustomAuthorizeAttribute. And I have the attribute declared on the Index action of TestController. It turns out that for the MVC3 project, AuthorizeCore is not getting called at all. It seems like when I put CustomAuthorizeAttribute on top of TestController.Index() the menu item corresponding to it will just be hidden. Any thoughts on this will be appreciated.
Thanks a lot,
Ben