I have 2 Domain Service in my Silverlight solution, both of them has RequiresAuthentication attribute. When开发者_如何转开发 user go to application and they login, they can call service A and it working properly but when user call service B it throw exception Load operation failed for query 'X'. Access to operation 'X' was denied.
How to fix this problem?
You need an authentication service as mentioned in the comment that likely does not have RequiresAuthentication set, unless you wish to do your authentication in ASP.NET first and then why bother with that service?
I implemented my services as defined here: http://www.codeproject.com/KB/silverlight/IssueVisionSilverlightPt3.aspx#AuthenticationService
but what wasn't apparent is in ValidateUser(userName, password, out userData)
, userData can not be null here or FormsAuthentication.Encrypt(ticket)
will always return null and therefor not set your auth cookie for Silverlight to send to your domain service requests. You can determine if the cookie is being sent by using Fiddler and you absolutely need this for the auth and domain services to "talk to each other".
The more quirky part is [EnableClientAccess(RequiresSecureEndpoint = true)]
as this seems to want requiresSSL=true in your web.config forms section and all traffic has to pass through https. For me this means detecting this on the client and redirecting before any auth is triggered.
精彩评论