<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Al Pascual ASP.NET Blog : .NET RIA Service</title><link>http://weblogs.asp.net/albertpascual/archive/tags/.NET+RIA+Service/default.aspx</link><description>Tags: .NET RIA Service</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>.NET RIA Services Part 4: Calling methods on the Server from Silverlight.</title><link>http://weblogs.asp.net/albertpascual/archive/2009/09/08/net-ria-services-part-4-calling-methods-on-the-server-from-silverlight.aspx</link><pubDate>Tue, 08 Sep 2009 13:26:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7196543</guid><dc:creator>albertpascual</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/albertpascual/rsscomments.aspx?PostID=7196543</wfw:commentRss><comments>http://weblogs.asp.net/albertpascual/archive/2009/09/08/net-ria-services-part-4-calling-methods-on-the-server-from-silverlight.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://alpascual.com/blog/working-on-silverlight-net-ria-services-part-2/" target="_blank"&gt;In Part 2 I introduced&lt;/a&gt; the concept of sharing code between tiers. When creating a new class in ASP.NET with the name .shared, .NET RIA Service will generate a hidden class as well in Silverlight with the same code. So you are compiling the code once in each tier, yet they’ll be insync.&amp;#160; This is called the RIA Link.&lt;/p&gt;  &lt;p&gt;Now that causes the problem that you are writing server side code that will run in the browser instead of the server, so its important to think about where do you want the code to run.&lt;/p&gt;  &lt;p&gt;&lt;u&gt;&lt;em&gt;Executing ASP.NET methods from the Client.&lt;/em&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;.NET RIA Services also provides a set of Silverlight controls to access data in the Server like the Domain Data Source. This control will send a query on the Silverlight load to consume data from the server and presenting that to the Silverlight tier. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_4A0BF684.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_3E763945.png" width="173" height="174" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Though you won’t find it on the ToolBox after installing .NET RIA Services, you can add a namespace and type it by hand.&lt;/p&gt;  &lt;p&gt;First add the reference to System.Windows.Ria.Controls and recompile the Silverlight application.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_5705D695.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_6876376D.png" width="244" height="205" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Add the namespace on the UserControl:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_35A630F9.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_1BD1FACA.png" width="417" height="68" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;and once you type the control, intellisense will provide you the rest. &lt;/p&gt;  &lt;p&gt;&amp;lt;riaControls:DomainDataSource x:Name=&amp;quot;myriaControl&amp;quot; /&amp;gt;&lt;/p&gt;  &lt;p&gt;Of course you now need to query the data you want to consume using control parameters. Domain Data Sources are very powerful, if you used ASP.NET data sources you’ll be half way there. They give you the ability to sort, filter, edit, paging and grouping as well. I highly recommend you play with them consuming known data to understand further how they work.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;u&gt;&lt;em&gt;Using the .NET RIA Services Class Libraries.&lt;/em&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;From the July 09 release with .NET RIA Services, the developer can create libraries in ASP.NET that can be also referenced in any Silverlight application. The library will be a single entity and assembly instead of making a copy of itself to be in multiple projects. Yet they’ll be a link between both tiers.&lt;/p&gt;  &lt;p&gt;Create a new .NET RIA Services Class library, found on your template with calling New Project&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_463E2BE7.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_3A3C3BB3.png" width="387" height="248" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;To use this library, you’ll need to Add a Reference from ASP.NET website as well as add the reference to that library from the Silverlight project.&lt;/p&gt;  &lt;p&gt;Now that library cannot have references to libraries outside the .NET 3.5 dlls. Adding a COM library will cause a compiling error when .NET RIA Services tries to recompile it to use in Silverlight. Yet there is a huge advantage in using these libraries, yet still the 2 projects that will be generated will exist inside a directory.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_597EE286.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_38F7A2D4.png" width="244" height="240" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The results shows 2 libraries. in a folder. When you select to add a reference for the Web application (ASP.NET) you’ll be able to select the RIA Service Library &lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_6A831069.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_1EB739B0.png" width="244" height="140" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Make sure you added in Silverlight as well as ASP.NET.&lt;/p&gt;  &lt;p&gt;Now write a method on the Silverlight project just created:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_5042A745.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_01CE14DB.png" width="335" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Then in ASP.NET you can see the method:&lt;/p&gt;  &lt;p&gt;namespace SilverlightApplicationRIA.Web    &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public partial class _Default : System.Web.UI.Page     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; protected void Page_Load(object sender, EventArgs e)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; RIAServicesLibrary1.Class1 myclass = new RIAServicesLibrary1.Class1();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; myclass.fooRia();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;Easy to now consume methods from Silverlight with ASP.NET. In the Part 2 we saw how to consume ASP.NET data from Silverlight, the sample above is a good example how to consume Silverlight data from the ASP.NET tier.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Site Note:&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;One thing I haven’t being able to figure it out, if why the .Web project gets created, I thought you can in RIA access that ASP.NET library, so who can access that library created and how is the link established?&amp;#160; I cannot access the 2 classes below I created in Silverlight or ASP.NET.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_7CEB611E.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_47729EF9.png" width="204" height="181" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;u&gt;&lt;em&gt;To answer a few emails: Question) How can I have an application like the business template without Authentication?&lt;/em&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;To answer people asking me about the business application, you can just use the navigation application template that does not include the .NET RIA services and the Authentication won’t be enable by default.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_3FE72F8C.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_2612F95D.png" width="327" height="233" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Visual Studio 2008 will ask you if you want to enable .NET RIA Services, I suggest you to enable that to enjoy the powerful Silverlight and ASP.NET communication, yet the result will be what you are looking for, a template like the one in Part 3 without the Login/Logout controls.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_7E6C7D32.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_24CE607E.png" width="244" height="217" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Cheers&lt;/p&gt;  &lt;p&gt;Al&lt;/p&gt;  &lt;p&gt;PS: Best resource for &lt;a href="http://blogs.msdn.com/brada/" target="_blank"&gt;.NET RIA Service posted by Brad Abrams&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.twitter.com/alpascual" target="_blank"&gt;Follow me at Twitter&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7196543" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/albertpascual/archive/tags/.NET+RIA+Service/default.aspx">.NET RIA Service</category><category domain="http://weblogs.asp.net/albertpascual/archive/tags/Silverlight+3/default.aspx">Silverlight 3</category></item><item><title>Part 3: Accessing Security and Authentication in Silverlight using .NET RIA Services.</title><link>http://weblogs.asp.net/albertpascual/archive/2009/09/04/part-3-accessing-security-and-authentication-in-silverlight-using-net-ria-services.aspx</link><pubDate>Sat, 05 Sep 2009 02:25:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7192006</guid><dc:creator>albertpascual</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/albertpascual/rsscomments.aspx?PostID=7192006</wfw:commentRss><comments>http://weblogs.asp.net/albertpascual/archive/2009/09/04/part-3-accessing-security-and-authentication-in-silverlight-using-net-ria-services.aspx#comments</comments><description>&lt;p&gt;Please &lt;a href="http://alpascual.com/tags/net-ria-services/"&gt;read the previous post from this series&lt;/a&gt; you can catch up.&lt;/p&gt;  &lt;p&gt;I have received many questions about the previous post of how the proxy files actually work. I was looking how .NET RIA Service connects ASP.NET and Silverlight, I was expecting the code that I call from Silverlight using the generated proxy file to call the ASP.NET in the server, yet this is not the case, .NET RIA Service makes a complete copy of the file and compiles it under Silverlight, so all the shared code is just that, 2 different classes, one running in ASP.NET and the other running in Silverlight. That’s why you need to make sure the classes you use in ASP.NET are 3.5 compatible.&lt;/p&gt;  &lt;p&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;u&gt;Authentication with .NET RIA Services.&lt;/u&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;Creating a Silverlight application and using the Checkbox to enable that project for ,NET RIA services won’t give you everything you need to use the .NET RIA Services Authentication right now, I do not know if that will change on the release version. &lt;/p&gt;  &lt;p&gt;The concept is great, yet, .NET RIA Services is still in development and I believe they haven’t added the “Authentication Domain Service” to secure your Silverlight application with the ASP.NET security context.&lt;/p&gt;  &lt;p&gt;For Authentication .NET RIA Service need to be a little different, as need to run on the ASP.NET, even if you call it from Silverlight. So you want to Authenticate a user from Silverlight and you add this code:&lt;/p&gt;  &lt;p&gt;namespace SilverlightApplicationRIA    &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public partial class MainPage : UserControl     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public MainPage()     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; InitializeComponent();&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; RiaContext.Current.Authentication.Login(&amp;quot;al&amp;quot;, &amp;quot;pascual&amp;quot;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;You’ll receive this error from the .NET RIA Services letting you know you need to create a Context first.&lt;/p&gt;  &lt;p&gt;“No contexts have been added to the Application's lifetime objects. For RiaContextBase.Current to resolve correctly, add a single context to the lifetime objects.”&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_119758B4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_474C9E0E.png" width="362" height="134" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So doesn’t work out of the box, you need to configure ASP.NET with a Membership provider and enable authentication on the web.config. The fastest way is to enable Windows Authentication, then create a Domain Service, go to Add –&amp;gt; New Item and select “Authentication Domain Service” &lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_2D0C34EA.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_5CE6D6AB.png" width="201" height="262" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This is where the problem starts, you won’t be able to find these item in the list. The item is missing on the lastest .NET RIA Service from July sample.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;u&gt;&lt;em&gt;Using the Business Application Template for Security enable application.&lt;/em&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;So if you want Authentication in .NET RIA Services, you’ll have to create a new project instead of just linking or enabling .NET RIA Services.&lt;/p&gt;  &lt;p&gt;Go to create a new project, select Silverlight and “Silverlight Business Application” to create a new application with many things build in for you.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_6255474F.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_00BF8839.png" width="244" height="211" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click to register a new user/.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_71A8A95E.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_25709FB0.png" width="244" height="179" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Upon registration and also login in, Silverlight talks to ASP.NET using .NET RIA Services, the biggest concern for developers is how to prevent the credentials to be seen by anybody as the client needs to send it to the server.&lt;/p&gt;  &lt;p&gt;I added Fiddler in the middle to see the communication between the client and the server. Silverlight sends in a post sending the username and password in text.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;POST /ria/ClientBin/DataService.axd/BusinessApplication1-Web-AuthenticationService/Login HTTP/1.1      &lt;br /&gt;Accept: */*       &lt;br /&gt;Content-Length: 58       &lt;br /&gt;Content-Type: application/x-www-form-urlencoded       &lt;br /&gt;Accept-Encoding: gzip, deflate       &lt;br /&gt;User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0)       &lt;br /&gt;Host: alhome       &lt;br /&gt;Connection: Keep-Alive       &lt;br /&gt;Pragma: no-cache &lt;/p&gt;    &lt;p&gt;userName=al&amp;amp;password=hellowworld3%23%23&amp;amp;isPersistent=False&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Works the same way than in ASP.NET with a post into the server, then&amp;#160; is the server that checks the database and does the authentication. So the best way to secure that communication will be using SSL if you do not want to protect the credentials.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_3D27D716.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_3B770B42.png" width="324" height="132" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Credentials get stored into a File database on ASP.NET.&lt;/p&gt;  &lt;p&gt;This template is using the Authentication context to the server&lt;/p&gt;  &lt;p&gt;private AuthenticationService _authService = RiaContext.Current.Authentication;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;u&gt;&lt;em&gt;Securing a Silverlight object using Roles in Silverlight and .NET RIA Services.&lt;/em&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;So this sample will explain using the ESRI Silverlight Map Control, coolest Silverlight control out there, how to protect using Authentication Roles a object in Silverlight.&lt;/p&gt;  &lt;p&gt;In the Home UserControl I added the ESRI Silverlight Map and change the visibility depending on the user authentication.&lt;/p&gt;  &lt;p&gt;public Home()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; InitializeComponent(); &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (RiaContext.Current.Authentication.IsLoggingIn == true)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; MyMap.Visibility = Visibility.Visible;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; MyMap.Visibility = Visibility.Collapsed; &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; RiaContext.Current.Authentication.LoggedIn += new EventHandler&amp;lt;System.Windows.Ria.ApplicationServices.AuthenticationEventArgs&amp;gt;(Authentication_LoggedIn);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; RiaContext.Current.Authentication.LoggedOut += new EventHandler&amp;lt;System.Windows.Ria.ApplicationServices.AuthenticationEventArgs&amp;gt;(Authentication_LoggedOut);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; void Authentication_LoggedOut(object sender, System.Windows.Ria.ApplicationServices.AuthenticationEventArgs e)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; MyMap.Visibility = Visibility.Collapsed;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; void Authentication_LoggedIn(object sender, System.Windows.Ria.ApplicationServices.AuthenticationEventArgs e)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; MyMap.Visibility = Visibility.Visible;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_0BD8ECB6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_6F0F51D3.png" width="244" height="180" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;As well I register the events for login and logout to make sure I hide the map when the user logout.&lt;/p&gt;  &lt;p&gt;You can register a username and password or use:&lt;/p&gt;  &lt;p&gt;username: test&lt;/p&gt;  &lt;p&gt;password: test123!&lt;/p&gt;  &lt;p&gt;This is how .NET RIA Services shows the best way to use Role base security using Silverlight.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Hope this helps&lt;/p&gt;  &lt;p&gt;Cheers&lt;/p&gt;  &lt;p&gt;Al&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7192006" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/albertpascual/archive/tags/.NET+RIA+Service/default.aspx">.NET RIA Service</category><category domain="http://weblogs.asp.net/albertpascual/archive/tags/Silverlight+3/default.aspx">Silverlight 3</category></item><item><title>Working on Silverlight .NET RIA Services Part 2</title><link>http://weblogs.asp.net/albertpascual/archive/2009/09/02/working-on-silverlight-net-ria-services-part-2.aspx</link><pubDate>Thu, 03 Sep 2009 03:46:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7189327</guid><dc:creator>albertpascual</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/albertpascual/rsscomments.aspx?PostID=7189327</wfw:commentRss><comments>http://weblogs.asp.net/albertpascual/archive/2009/09/02/working-on-silverlight-net-ria-services-part-2.aspx#comments</comments><description>&lt;p&gt;If you haven’t &lt;a href="http://alpascual.com/blog/starting-with-net-ria-services/"&gt;please read part 1 before&lt;/a&gt; reading this post.&lt;/p&gt;  &lt;p&gt;The most powerful thing about .NET RIA Services besides the whole framework, is the concept of sharing code from ASP.NET and Silverlight without extra steps and setting up Web Services manually. .NET RIA services provides you an automatic creation of the proxy classes to share the code between those 2 tiers.&lt;/p&gt;  &lt;p&gt;.NET RIA Services is simple, yet introduces a few things for the developer to learn, I hope this simple tutorial will help learn those.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;u&gt;How to share new code.&lt;/u&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;We create a class on the ASP.NET tier.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_36511F40.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_4E74899B.png" width="336" height="200" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;using System;    &lt;br /&gt;using System.Collections.Generic;     &lt;br /&gt;using System.Linq;     &lt;br /&gt;using System.Web; &lt;/p&gt;  &lt;p&gt;namespace SilverlightApplicationRIA.Web.MyCode    &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class MyClass     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string foo()     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return &amp;quot;Hello World&amp;quot;;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Writing something so simple and compiling it will generate a proxy file in Silverlight to be created, the key is to name your classes with .shared in order for the .NET RIA Service to pick it up and generate the proxy class.&lt;/p&gt;  &lt;p&gt;If we look into the Silverlight application will find hidden files in the project that you can see going to the Windows Explorer.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_58C5ADFB.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_4D2FF0BC.png" width="204" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;u&gt;How to share existing code.&lt;/u&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;You can select an existing file and select to Add Link instead of just add to create the same file in both tiers.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_779C21D9.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_36F9D56A.png" width="244" height="192" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This option is important to use existing items that you want to exist in both tiers, the physical files are not copied, it just creates a link between them in the hard disk.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;u&gt;&lt;em&gt;How to share a library.&lt;/em&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;You can share .NET 3.5 libraries with Silverlight 3.0. This is what makes .NET RIA Services great, write it once, share it twice. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;u&gt;Consuming the shared code in Silverlight.&lt;/u&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;The pattern to consume the code in Silverlight from .NET RIA Services is pretty simple as if you remember there is a proxy copy on Silverlight created. So just add the correct namespace and execute the method synch not asynch like you would do in a web service for Silverlight.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_3D40ABF8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_159A2FCE.png" width="292" height="132" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;public partial class MainPage : UserControl    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public MainPage()     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; InitializeComponent(); &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SilverlightApplicationRIA.Web.MyCode.MyClass myClass = new SilverlightApplicationRIA.Web.MyCode.MyClass();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string sText = myClass.foo();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;The sText will show a “Hello World” answer.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;u&gt;What about accessing to the ASP.NET Security.&lt;/u&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;I’ll cover this part extensively on part 3 of this series, yet to quickly answer the question of all of you that email me about this, you can in Silverlight consume the security context of the ASP.NET application by using the RiaContext class.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/albertpascual/image_0A04728F.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/albertpascual/image_thumb_697D32DC.png" width="244" height="149" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Happy .NET RIA Services coding.&lt;/p&gt;  &lt;p&gt;Cheers&lt;/p&gt;  &lt;p&gt;Al&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7189327" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/albertpascual/archive/tags/.NET+RIA+Service/default.aspx">.NET RIA Service</category><category domain="http://weblogs.asp.net/albertpascual/archive/tags/Silverlight+3/default.aspx">Silverlight 3</category></item><item><title>Silverlight 2.0 Authentication Services.</title><link>http://weblogs.asp.net/albertpascual/archive/2009/06/30/silverlight-2-0-authentication-services.aspx</link><pubDate>Wed, 01 Jul 2009 04:42:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7137398</guid><dc:creator>albertpascual</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/albertpascual/rsscomments.aspx?PostID=7137398</wfw:commentRss><comments>http://weblogs.asp.net/albertpascual/archive/2009/06/30/silverlight-2-0-authentication-services.aspx#comments</comments><description>&lt;p&gt;Message based authentication managed by Silverlight not the browser. &lt;/p&gt;  &lt;p&gt;Silverlight can use the browsers cookies and send them to the hosts. When you authenticate with ASP.NET the authentication cookie stored to your computer will be used by Silverlight if you create a Silverlight Authentication Service&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Create a service.svc make sure to select the Silverlight Service.&lt;/p&gt;  &lt;p&gt;&amp;lt;%@ ServiceHost Language=&amp;quot;C#&amp;quot; Service=&amp;quot;System.Web.ApplicationServices.AuthenticationService %&amp;gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;On your web.config add the service to be enable it.&lt;/p&gt;  &lt;p&gt;&amp;lt;!-- this enables the WCF AuthenticationService endpoint --&amp;gt; &amp;lt;service name=&amp;quot;System.Web.ApplicationServices.AuthenticationService&amp;quot; behaviorConfiguration=&amp;quot;AuthenticationServiceTypeBehaviors&amp;quot;&amp;gt; &amp;lt;endpoint contract=&amp;quot;System.Web.ApplicationServices.AuthenticationService&amp;quot; binding=&amp;quot;basicHttpBinding&amp;quot; bindingConfiguration=&amp;quot;userHttp&amp;quot; bindingNamespace=&amp;quot;http://asp.net/ApplicationServices/v200&amp;quot;/&amp;gt; &amp;lt;/service&amp;gt; &lt;/p&gt;  &lt;p&gt;Then just connect to the service as a service web reference and use the methods for the authentication&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Related posts&lt;/h4&gt;  &lt;p&gt;&lt;a title="http://blogs.msdn.com/brada/archive/2008/05/03/accessing-the-asp-net-authentication-profile-and-role-service-in-silverlight.aspx" href="http://blogs.msdn.com/brada/archive/2008/05/03/accessing-the-asp-net-authentication-profile-and-role-service-in-silverlight.aspx"&gt;http://blogs.msdn.com/brada/archive/2008/05/03/accessing-the-asp-net-authentication-profile-and-role-service-in-silverlight.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://blogs.msdn.com/brada/archive/2008/06/23/using-asp-net-authentication-in-a-web-service-with-silverlight.aspx" href="http://blogs.msdn.com/brada/archive/2008/06/23/using-asp-net-authentication-in-a-web-service-with-silverlight.aspx"&gt;http://blogs.msdn.com/brada/archive/2008/06/23/using-asp-net-authentication-in-a-web-service-with-silverlight.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Cheers&lt;/p&gt;  &lt;p&gt;Al&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/alpascual"&gt;Follow me in twitter&lt;/a&gt; | &lt;a href="http://silverlightme.net/"&gt;bookmark me&lt;/a&gt; | &lt;a href="http://alpascual.com/blog/al/rss.aspx"&gt;Subscribe to my feed&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7137398" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/albertpascual/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/albertpascual/archive/tags/.NET+RIA+Service/default.aspx">.NET RIA Service</category><category domain="http://weblogs.asp.net/albertpascual/archive/tags/Silverlight+2.0/default.aspx">Silverlight 2.0</category><category domain="http://weblogs.asp.net/albertpascual/archive/tags/Silverlight+3/default.aspx">Silverlight 3</category></item><item><title>Patterns: What is .net RIA Services?</title><link>http://weblogs.asp.net/albertpascual/archive/2009/05/25/patterns-what-is-net-ria-services.aspx</link><pubDate>Tue, 26 May 2009 04:59:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7097428</guid><dc:creator>albertpascual</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/albertpascual/rsscomments.aspx?PostID=7097428</wfw:commentRss><comments>http://weblogs.asp.net/albertpascual/archive/2009/05/25/patterns-what-is-net-ria-services.aspx#comments</comments><description>&lt;p&gt;Microsoft is getting big in Patterns and practices, something that architects really like to see. I personally like to follow a pattern instead of designing my own, laziness? Probably not, whatever I came out with, won’t be as good as a team or people with more time and more intelligence. &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Microsoft .NET RIA Services simplifies the traditional n-tier application pattern by bringing together the ASP.NET and Silverlight platforms. The RIA Services provides a pattern to write application logic that runs on the mid-tier and controls access to data for queries, changes and custom operations. It also provides end-to-end support for common tasks such as data validation, authentication and roles by integrating with Silverlight components on the client and ASP.NET on the mid-tier.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;a title="http://silverlight.net/forums/t/95364.aspx" href="http://silverlight.net/forums/t/95364.aspx"&gt;http://silverlight.net/forums/t/95364.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Typical ASP.NET pattern&lt;/p&gt;  &lt;p&gt;&lt;img alt="Classic Web Application" src="http://www.nikhilk.net/Content/Posts/RIAServices/WebApp.png" /&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;New Silverlight or RIA pattern&lt;/p&gt;  &lt;p&gt;&lt;img alt="Rich Internet Application" src="http://www.nikhilk.net/Content/Posts/RIAServices/RIA.png" /&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The .NET RIA Services framework makes it easy to create application logic that can be shared across tier boundaries. One of the built-in mechanisms for this is a convention-based approach to naming source files that allows files on the server to be replicated in the client project. Because the framework also generates client proxy types that match those on the server, these files can cross-compile between the two projects.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=76bb3a07-3846-4564-b0c3-27972bcaabce&amp;amp;displaylang=en"&gt;Download the .NET RIA Services here&lt;/a&gt; You’ll need Silverlight 3 in order to make it work.&lt;/p&gt;  &lt;p&gt;What about Security? The User Service provided in the RIA Services framework encapsulates authentication, authorization, and user profile. It makes verifying and tracking user identity a simple part of application development&lt;/p&gt;  &lt;p&gt;One feature the framework offers is passing the initial client state with the HTML page. For Windows authentication and persistent Forms authentication, this provides an initial state to the client without the need for an additional load call. Currently this feature is available as part of the &lt;i&gt;SilverlightApplication&lt;/i&gt; control. To enable serializing the initial client state, replace the default &lt;i&gt;Silverlight&lt;/i&gt; control with the &lt;i&gt;SilverlightApplication&lt;/i&gt; control.&lt;/p&gt;  &lt;p&gt;I’m very exited about where Microsoft is taking Silverlight and how they are working on Patterns already for the enterprise with a mix of ASP.NET.&lt;/p&gt;  &lt;p&gt;If you are developing applications in Silverlight that are going to production, this pattern is for you to stay into the models defined. &lt;/p&gt;  &lt;p&gt;&lt;u&gt;&lt;strong&gt;Message based authentication managed by Silverlight not the browser. &lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;Silverlight can use the browsers cookies and send them to the hosts. When you authenticate with ASP.NET the authentication cookie stored to your computer will be used by Silverlight if you create a Silverlight Authentication Service &lt;/p&gt;  &lt;p&gt;Create a service.svc make sure to select the Silverlight Service.&lt;/p&gt;  &lt;p&gt;&amp;lt;%@ ServiceHost Language=&amp;quot;C#&amp;quot; Service=&amp;quot;System.Web.ApplicationServices.AuthenticationService %&amp;gt;&lt;/p&gt;  &lt;p&gt;On your web.config add the service to be enable it.&lt;/p&gt;  &lt;p&gt;&amp;lt;!-- this enables the WCF AuthenticationService endpoint --&amp;gt; &amp;lt;service name=&amp;quot;System.Web.ApplicationServices.AuthenticationService&amp;quot; behaviorConfiguration=&amp;quot;AuthenticationServiceTypeBehaviors&amp;quot;&amp;gt; &amp;lt;endpoint contract=&amp;quot;System.Web.ApplicationServices.AuthenticationService&amp;quot; binding=&amp;quot;basicHttpBinding&amp;quot; bindingConfiguration=&amp;quot;userHttp&amp;quot; bindingNamespace=&amp;quot;http://asp.net/ApplicationServices/v200&amp;quot;/&amp;gt; &amp;lt;/service&amp;gt; &lt;/p&gt;  &lt;p&gt;Then just connect to the service as a service web reference and use the methods for the authentication. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://alpascual.com/blog/what-s-silverlight-prism/"&gt;Composite Application Guidance for WPF&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Cheers&lt;/p&gt;  &lt;p&gt;Al&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7097428" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/albertpascual/archive/tags/.NET+RIA+Service/default.aspx">.NET RIA Service</category><category domain="http://weblogs.asp.net/albertpascual/archive/tags/Silverlight+2.0/default.aspx">Silverlight 2.0</category><category domain="http://weblogs.asp.net/albertpascual/archive/tags/Silverlight+3/default.aspx">Silverlight 3</category></item></channel></rss>