locked
URGENT--SilverLight 2 Beta 2 Cross Domain Support does not work with ADO.NET Service RRS feed

  • Question

  • Hi,

     

    I Dropped the ClientAccessPolicy.xml file to the domain root of the website hosting the ADO.NET Data Service. When I try to access this service from a SilverLight control hosted in another Domain, I get an error.

     

    However this works fine when I move the silverlight control to the same website that hosts  the ADO.NET Data service.

     

    Inspite of Silverlight supporting Cross Domain calls (Beta 2, through Cross Domain Policy Files), why does ADO.NET Data service not support it?? This is supported by WCF Services.

     

    Am I missing some configuration??

     

    Please advice

     

    Sanjeev

    Tuesday, June 10, 2008 11:13 AM

Answers

  • Hi,

     

    Unfortunately, due to work arounds required for other aspects of Data Services functionality, cross-domain access is not supported in the Data Services client included in Silverlight Beta 2. We're working to sort out the issue for the RTM release.

     

    Pablo Castro
    Software Architect
    Microsoft Corporation
    http://blogs.msdn.com/pablo

     

     

    Tuesday, June 10, 2008 11:35 PM
    Moderator

All replies

  • Hi,

     

    Unfortunately, due to work arounds required for other aspects of Data Services functionality, cross-domain access is not supported in the Data Services client included in Silverlight Beta 2. We're working to sort out the issue for the RTM release.

     

    Pablo Castro
    Software Architect
    Microsoft Corporation
    http://blogs.msdn.com/pablo

     

     

    Tuesday, June 10, 2008 11:35 PM
    Moderator
  • Has this been fixed in .NET Framework SP1 release?

     

    Wednesday, August 27, 2008 12:57 PM
  •  

    I doubt it, SL Beta 2 is non compatale with SP1. We will have to wait for the release of SL2.0, when that is....??
    Wednesday, August 27, 2008 7:15 PM
  • Unfortunately we weren't able to include support for cross-domain access in the Data Services client library even in the SL 2 RTM bits, due to limitations in the SL 2 runtime itself.

     

    To be clear: the SL 2 HTTP client does have support for cross-domain access and you can continue to rely on that. What's not supported is use of the Data Services client across domains.

     

    Pablo Castro
    Software Architect
    Microsoft Corporation
    http://blogs.msdn.com/pablo

     

    Friday, August 29, 2008 12:40 AM
    Moderator
  •  

    Is there a work-around in RC0 for accessing Data Services across domains?
    Monday, October 6, 2008 2:21 AM
  • Hi Wes,

      There is no support for accessing cross-domain ADO.NET Data Services using the Silverlight client library in this  release. The networking stack provided by Silverlight allows you to access cross domain data services. so, if you dont use the DataServiceContext and  instead use HttpWebRequest to access the data service then you will have cross domain access to the data service.
    Cross-domain access to ADO.NET Data Services with the Silverlight client library is not allowed in SL2 RC0/RTM bits.

    Monday, October 6, 2008 2:47 AM
    Moderator
  • Thank you for your reply!

    Does that mean that I can use the DataSvcUtil.exe tool to generate a class then it'll work, but it will not if I add it to my silverlight project as a service?
     
    Edit:  Nevermind...I see that doesn't really generate HttpRequests like I hoped it would.
    Monday, October 6, 2008 3:46 PM
  • Hi WesAd,

     

     I think you mean generating the client layer and using in a desktop application as compared to using the client  layer in a Silverlight application.

    The Desktop application has no concept of Internet Explorer Domains , so it will work across services hosted on any domain.  
    The Client library , when used in a Silverlight application , will only be able to access Data Services hosted in the same domain as the page hosting the Silverlight application.

     

    The problem with Cross-Domain access for ADO.NET Data Services Silverlight client is a bit involved.

    The core networking api provided by Silverlight is limited in functionality.
    You can read Wilco's blog post here about the changes to the Networking API in Silverlight v2.

    Having a limited set of Status Codes ( 200 and 404 ) and verbs ( GET /POST ) is
    not really all that helpful when you are building a Hi-REST client library .

    Our only options were ,

    1) Use the Silverlight networking library and lose a significant portion of the functionality
    compared to the desktop library.

    2) Write our own networking library from scratch for silverlight and lose Cross-Domain access .

     

    For this release , we went with Option 2 to make sure that we had a full-featured Silverlight client library.

    Tuesday, October 7, 2008 12:33 AM
    Moderator
  • Hi all,
    In the CTP2 release of ADO.NET Data Services v1.5 , we have added support for X-Domain and Out Of Browser data access in the ADO.NET Data Services Client library.
    For more instructions , go here : http://blogs.msdn.com/astoriateam/archive/2009/08/31/ado-net-data-services-v1-5-ctp2-now-available-for-download.aspx
    Phani Raj Astoria http://blogs.msdn.com/PhaniRaj
    Tuesday, September 1, 2009 4:44 AM
    Moderator
  • Hello,Moderator!I made a silverlight site, with ADO.NET Data Service,and two file that SilverlightApplication10.Web(SilverlightApplication10TestPage.html) and SilverlightApplication10(MainPage.xaml).The MainPage code :
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using System.Data.Services.Client;
    using System.Collections.ObjectModel;
    using SilverlightApplication10.ServiceReference1;
    namespace SilverlightApplication10
    {
        public partial class MainPage : UserControl
        {
            uuserEntities proxy;
            ObservableCollection<UserTest> obsvCollCustomers;
            public MainPage()
            {
                InitializeComponent();
                this.Loaded += OnLoaded;
            }
            void OnLoaded(object sender, EventArgs args)
            {
                proxy = new uuserEntities(
                        new Uri("http://localhost:2475/WebDataService1.svc", UriKind.Absolute));
                obsvCollCustomers = new ObservableCollection<UserTest>();
            }
    
            void OnGetData(object sender, EventArgs args)
            {
                DataServiceQuery<UserTest> query =
                    (DataServiceQuery<UserTest>)
                    (from c in proxy.UserTests
                     select c);
    
                query.BeginExecute(GetDataCallback, query);
    
            }
    
            void GetDataCallback(IAsyncResult result)
            {
                try
                {
                    DataServiceQuery<UserTest> queryResult =
                                   (DataServiceQuery<UserTest>)result.AsyncState;
    
                    IEnumerable<UserTest> results =
                                  queryResult.EndExecute(result);
    
                    foreach (var item in results)
                        obsvCollCustomers.Add(item);
    
                    Dispatcher.BeginInvoke(() =>
                    {
                        dataGrid1.DataContext = obsvCollCustomers;
                    });
                }
                catch (DataServiceRequestException ex)
                {
                    ex.Response.ToString();
                }
            }
    
            void OnInserted(object sender, EventArgs args)
            {
                UserTest newCustomer = new UserTest();
                newCustomer.UserID = textBoxCustomerID.Text;
                newCustomer.UserName = textBoxCompanyName.Text;
    
    
                proxy.AddToUserTests(newCustomer);
                proxy.BeginSaveChanges(OnSaveChangesCompleted, newCustomer);
    
            }
    
            void OnSaveChangesCompleted(IAsyncResult result)
            {
                try
                {
                    proxy.EndSaveChanges(result);
    
                    obsvCollCustomers.Add(result.AsyncState as UserTest);
                    textBlock.Text = "Insert complete: " +
                                       (result.AsyncState as UserTest).UserName;
                }
                catch (DataServiceRequestException ex)
                {
                    textBlock.Text = "OnSaveChangesCompleted Error: " + ex.Response.ToString();
                }
            }
    
        }
    }
     
       When Debugging in vs 2008,there's not problem.But when I take the site on the IIS6.0,that the Grid data can't show.Can't attach the WebDataService1.svc,I have tried add clientaccesspolicy.xml in the site or other methods  ,but  does not solve the problem!
      SO, HOPING YOU ADVICE SOON!
      By poor coder.
    Thanks for any help!
    Saturday, September 26, 2009 6:21 AM