서비스에 대한 액세스를 허용하는 clientaccesspolicy.xml 파일을 만듭니다. 다음 구성을 사용하면 다른 모든 도메인에서 현재 도메인의 모든 리소스에 액세스할 수 있습니다.

clientaccesspolicy.xml 
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-request-headers="*">
        <domain uri="*"/>
      </allow-from>
      <grant-to>
        <resource path="/" include-subpaths="true"/>
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>
 
crossdomain.xml 파일을 사용하여 도메인 간 액세스를 허용하려면
<?xml version="1.0"?> <!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"> <cross-domain-policy> <allow-http-request-headers-from domain="*" headers="*"/> </cross-domain-policy>
 --------------------------------------------------------------------------------------------------------------
 
 
접근하기 테스트
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.IO;
namespace SilverlightApplicationCardTest
{
    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            WebClient wc = new WebClient();
            wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);
          //URL 여기에 clientaccesspolicy.xmlcrossdomain.xml 이 있어야 합니다

            wc.OpenReadAsync(new Uri("접근할려는 URL"));            
        }
        void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                Stream responseStream = e.Result;
                // Continue working with responseStream here...
                StreamReader sr = new StreamReader(responseStream);
                this.txt.Text = sr.ReadLine();
            }
        }

    }
}

+ Recent posts