Permissions Error when PrincipalPermission applied at class level

697 views Asked by At
[PrincipalPermission(SecurityAction.Demand, Role = "ValidRole")]
public partial class CustomerAdd : System.Web.UI.UserControl
{....

}

When I try the above code, I do not get the compile time error and the permissions are not applied. I am UNABLE to execute any of the code methods even for valid Roles. Even for valid roles, I get permission denied error.

This works for method level declaration but does not work for class level declaration.

Please let me know. Thanks

1

There are 1 answers

0
PhilDulac On

I ran into this problem last week and the only answer I found that make sense is:

That's because you've now set permissions on the constructor. Make sure the host that creates the service instances (IIS, Windows Service, etc) has permission to the service now.

Did some tests with ASP.NET Membership/Role providers and I can definitly tel that the user calling the constructor and the method are diffrent.