问题
I have a User class that implemented the IUser interface and is used in the AuthenticationService of my WCF RIA app.
Whenever I apply the RequiresRole attribute to one of my operations I get Access to the operation is denied error even though WebContext.User.IsInRole("Managers") on the client side returns true.
Does anyone know why I get this error?
Thanks.
回答1:
The reason WebContext.User.IsInRole
returns true because the IUser
has a property Roles
.
This property is set with the user's roles by the server at authentication/user-load time.
The result is that while the client has no access or knowledge on the persistent storage / server entities etc. of the roles in the server, it still has the primitive info (role names) that was rather provided to him by the server.
来源:https://stackoverflow.com/questions/3694277/problem-with-wcf-ria-services-requiresrole-attribute