This question is locked. New answers and comments are not allowed.
I've been working on this pretty extensively, and am finally 90% of the way there, but I am not able to figure out why IsAuthorized is not being called.
The attribute is configured here:
Debugging through the code, I can see that it the PanelBar calls the authorization code, and extracts the role (PCIIValidator), but it fails to call IsAuthorized(), instead it calls AuthorizeCore, and I have no idea why that is.
I do see in AuthorizeAttributeBuilder.WriteIsAuthorized() where it re-creates the method, and does some kind of override, but this is not working the way I desire.
One additional comment -- My project was originally in .Net 3.5 on VS2008. I have been trying to use VS2010, but a bug in resgen when targeting 3.5 is forcing me to run in .Net 4.0. I wonder if there's some incompatibility in 4.0.
I'm going to go back to VS2008.. which is a chore because there's a lot of projects to change, but obviously necessary! ;-(
- Daniel
Suggestions?
| [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] |
| public class PCIIAuthorizeAttribute : AuthorizeAttribute, IAuthorizeAttribute |
| { |
| #region IAuthorizeAttribute Members |
| private String[] _splitRoles = null; |
| public PCIIAuthorizeAttribute() { } |
| public virtual bool IsAuthorized(HttpContextBase httpContext) |
| { |
| if (httpContext == null) |
| throw new ArgumentException("httpContext"); |
| if (!PCIIService.IsLoggedIn()) |
| return true; |
| if (_splitRoles == null) |
| _splitRoles = Roles.Split(','); |
| if (PCIIService.HasRole(_splitRoles)) |
| return true; |
| return false; |
| } |
| #endregion |
| } |
The attribute is configured here:
| [SessionExpireFilter] |
| [PCIIAuthorize(Roles="PCIIValidator")] |
| public ActionResult Index(Guid? id ) |
| { |
Debugging through the code, I can see that it the PanelBar calls the authorization code, and extracts the role (PCIIValidator), but it fails to call IsAuthorized(), instead it calls AuthorizeCore, and I have no idea why that is.
I do see in AuthorizeAttributeBuilder.WriteIsAuthorized() where it re-creates the method, and does some kind of override, but this is not working the way I desire.
One additional comment -- My project was originally in .Net 3.5 on VS2008. I have been trying to use VS2010, but a bug in resgen when targeting 3.5 is forcing me to run in .Net 4.0. I wonder if there's some incompatibility in 4.0.
I'm going to go back to VS2008.. which is a chore because there's a lot of projects to change, but obviously necessary! ;-(
- Daniel
Suggestions?