<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Phil Leggetter - Software Consultant &#187; crossdomain</title>
	<atom:link href="http://www.leggetter.co.uk/tag/crossdomain/feed" rel="self" type="application/rss+xml" />
	<link>http://www.leggetter.co.uk</link>
	<description>Real-time web and social media software consultant</description>
	<lastBuildDate>Thu, 09 Sep 2010 14:17:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>How to make a cross domain web request with SilverLight 2</title>
		<link>http://www.leggetter.co.uk/2008/10/24/how-to-make-a-cross-domain-web-request-with-silverlight-2.html</link>
		<comments>http://www.leggetter.co.uk/2008/10/24/how-to-make-a-cross-domain-web-request-with-silverlight-2.html#comments</comments>
		<pubDate>Fri, 24 Oct 2008 12:16:18 +0000</pubDate>
		<dc:creator>Phil Leggetter</dc:creator>
				<category><![CDATA[thoughts]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[crossdomain]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.leggetter.co.uk/?p=60</guid>
		<description><![CDATA[To make a cross domain web request with SilverLight 2 r [...]


Related posts:<ol><li><a href='http://www.leggetter.co.uk/2009/10/30/using-fiddler-to-trick-silverlight-into-allowing-a-crossdomain-web-request.html' rel='bookmark' title='Permanent Link: Using Fiddler to trick Silverlight into allowing a crossdomain Web Request'>Using Fiddler to trick Silverlight into allowing a crossdomain Web Request</a></li>
<li><a href='http://www.leggetter.co.uk/2010/03/19/using-fiddler-to-help-develop-cross-domain-capable-javascript-web-applications.html' rel='bookmark' title='Permanent Link: Using Fiddler to help develop cross domain capable JavaScript web applications'>Using Fiddler to help develop cross domain capable JavaScript web applications</a></li>
<li><a href='http://www.leggetter.co.uk/2010/03/12/making-cross-domain-javascript-requests-using-xmlhttprequest-or-xdomainrequest.html' rel='bookmark' title='Permanent Link: Making cross domain JavaScript requests using XMLHttpRequest or XDomainRequest'>Making cross domain JavaScript requests using XMLHttpRequest or XDomainRequest</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>To make a cross domain web request with SilverLight 2 really isn&#8217;t that tough. I did have some problems with RC0 but I have no idea why. I just tried writing a little app to do this and it worked straight away.<br />
<span id="more-60"></span></p>
<p>Here&#8217;s the code. It&#8217;s obviously part of a full solution containing a Web Application and a SilverLight Application project. I&#8217;ve also <a  href="http://www.leggetter.co.uk/wp-content/uploads/2008/10/silverlightcrossdomainapplication.zip">uploaded it</a>.</p>
<h2>Useful Information:</h2>
<ul>
<li>You <strong>can not</strong> do a cross domain request over HTTPS.</li>
<li>You <strong>can</strong> do a cross domain request over HTTP.</li>
<li>To be able to make the cross domain request the server that you are making the request to needs to have either (requires clarification) <a  href="http://www.leggetter.co.uk/crossdomain.xml"> crossdomain.xml</a> and/or <a  href="http://www.leggetter.co.uk/clientaccesspolicy.xml">clientaccesspolicy.xml</a> in the root of the webserver.</li>
</ul>
<h2>Resources/links:</h2>
<div>
<ul>
<li><a  href="http://silverlight.net/forums/p/35194/106059.aspx#106059">SilverLight.net forum post on making a WCF cross domain request</a></li>
<li><a  href="http://timheuer.com/blog/archive/2008/04/06/silverlight-cross-domain-policy-file-snippet-intellisense.aspx">Cross domain policy file helpers for Visual Studio</a> &#8211; addes intellisense for the XML files</li>
<li><a  href="http://www.franksworld.com/Utilities/CrossDomainPolicyChecker/Default.aspx">Online cross domain policy file checker</a></li>
<li><a  href="http://www.leggetter.co.uk/wp-content/uploads/2008/10/silverlightcrossdomainapplication.zip">Silverlight cross domain web request example solution</a></li>
<li><a  href="http://www.leggetter.co.uk/crossdomain.xml">Example clientpolicy.xml</a> file<a  href="http://www.leggetter.co.uk/clientaccesspolicy.xml"></a></li>
<li><a href="http://www.leggetter.co.uk/clientaccesspolicy.xml">Example clientaccesspolicy.xml</a> file</li>
</ul>
</div>
<h2>The code:</h2>
<pre class="brush: csharp;">
private void RequestButton_Click(object sender, RoutedEventArgs e)
{
    try
    {
        // Create and being making the request/getting the response
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(&quot;http://www.leggetter.co.uk/&quot;));
        request.BeginGetResponse(HandleResponse, request);
    }
    catch (Exception ex)
    {
        Debug.WriteLine(ex);
    }
}

private void HandleResponse(IAsyncResult result)
{
    try
    {
        // Finish getting the response and then read the response in chunks
        HttpWebRequest request = (HttpWebRequest)result.AsyncState;
        HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);

        StringBuilder readText = new StringBuilder();
        using (Stream responseStream = response.GetResponseStream())
        {
            byte[] buffer = new byte[1024];
            int read = responseStream.Read(buffer, 0, buffer.Length);
            while (read &gt; 0)
            {
                readText.Append(Encoding.UTF8.GetString(buffer, 0, read));
                read = responseStream.Read(buffer, 0, buffer.Length);
            }
        }

        // Display the response text
        Dispatcher.BeginInvoke(delegate()
        {
            ResponseText.Text = readText.ToString();
        });
    }
    catch (Exception ex)
    {
        Debug.WriteLine(ex);
    }
}
</pre><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em> </em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.leggetter.co.uk%2F2008%2F10%2F24%2Fhow-to-make-a-cross-domain-web-request-with-silverlight-2.html&amp;title=How+to+make+a+cross+domain+web+request+with+SilverLight+2" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.leggetter.co.uk%2F2008%2F10%2F24%2Fhow-to-make-a-cross-domain-web-request-with-silverlight-2.html&amp;title=How+to+make+a+cross+domain+web+request+with+SilverLight+2" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Fwww.leggetter.co.uk%2F2008%2F10%2F24%2Fhow-to-make-a-cross-domain-web-request-with-silverlight-2.html&amp;title=How+to+make+a+cross+domain+web+request+with+SilverLight+2" rel="nofollow" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.leggetter.co.uk%2F2008%2F10%2F24%2Fhow-to-make-a-cross-domain-web-request-with-silverlight-2.html" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.leggetter.co.uk%2F2008%2F10%2F24%2Fhow-to-make-a-cross-domain-web-request-with-silverlight-2.html&amp;title=How+to+make+a+cross+domain+web+request+with+SilverLight+2" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.leggetter.co.uk%2F2008%2F10%2F24%2Fhow-to-make-a-cross-domain-web-request-with-silverlight-2.html&amp;title=How+to+make+a+cross+domain+web+request+with+SilverLight+2" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.leggetter.co.uk%2F2008%2F10%2F24%2Fhow-to-make-a-cross-domain-web-request-with-silverlight-2.html&amp;title=How+to+make+a+cross+domain+web+request+with+SilverLight+2" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.leggetter.co.uk%2F2008%2F10%2F24%2Fhow-to-make-a-cross-domain-web-request-with-silverlight-2.html" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+How+to+make+a+cross+domain+web+request+with+SilverLight+2+@+http%3A%2F%2Fwww.leggetter.co.uk%2F2008%2F10%2F24%2Fhow-to-make-a-cross-domain-web-request-with-silverlight-2.html" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.leggetter.co.uk%2F2008%2F10%2F24%2Fhow-to-make-a-cross-domain-web-request-with-silverlight-2.html&amp;t=How+to+make+a+cross+domain+web+request+with+SilverLight+2" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>Related posts:<ol><li><a href='http://www.leggetter.co.uk/2009/10/30/using-fiddler-to-trick-silverlight-into-allowing-a-crossdomain-web-request.html' rel='bookmark' title='Permanent Link: Using Fiddler to trick Silverlight into allowing a crossdomain Web Request'>Using Fiddler to trick Silverlight into allowing a crossdomain Web Request</a></li>
<li><a href='http://www.leggetter.co.uk/2010/03/19/using-fiddler-to-help-develop-cross-domain-capable-javascript-web-applications.html' rel='bookmark' title='Permanent Link: Using Fiddler to help develop cross domain capable JavaScript web applications'>Using Fiddler to help develop cross domain capable JavaScript web applications</a></li>
<li><a href='http://www.leggetter.co.uk/2010/03/12/making-cross-domain-javascript-requests-using-xmlhttprequest-or-xdomainrequest.html' rel='bookmark' title='Permanent Link: Making cross domain JavaScript requests using XMLHttpRequest or XDomainRequest'>Making cross domain JavaScript requests using XMLHttpRequest or XDomainRequest</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.leggetter.co.uk/2008/10/24/how-to-make-a-cross-domain-web-request-with-silverlight-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
