Here is a good exam开发者_JAVA百科ple how to create custom autorization for RIA services: RIA Services: How can I create custom authentication?
In my case a silverlight-pages will be displayed as a part of HTML-content and user authorisation is already implemented on the server-side (ASP.NET Membership is not used). It is required to show on the silverlight pages different information for authorised and non-authorised users.
Is there any possibility to track on the Silverlight side if user is already authorized on the server side (on the usual ASP.NET web-site)?
Please adivse how to do this.
Thank you in advance.
Several ways:
The simplest: if authentication results in a reload of the page (and therefore all the Silverlight apps), you can send an "IsAuthenticated" parameter value to the Silverlight application through a
<param name="IsAuthenticated" value="<%= IsAuthenticated %>" />
tag in the app's<object>
tag (in the loading HTML), or through theInitParameters
method of theasp:Silverlight
object, whichever one you're using; the parameter will be visible to the SL app in theInitParams
member of theStartupEventArgs
sent to the handler of the Application'sStartup
event.More complex: create a WCF HTTP Web Service (i.e. one that Silverlight can see) that contains a method that returns the user's current authentication status.
Of course, this only tells the SL app whether the user's authenticated, and does not help to lock down whatever information you're sending to the app -- in other words, the server should still check that the "authenticated-only" information is only being returned to requests from SL apps running in authenticated browser sessions. (Assuming that information is related to the authentication. If it's just a different set of banner ads, then no big deal.)
精彩评论