<?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>scorbs &#187; networking</title>
	<atom:link href="http://scorbs.com/tag/networking/feed/" rel="self" type="application/rss+xml" />
	<link>http://scorbs.com</link>
	<description>karen corby&#039;s fabulous blog</description>
	<lastBuildDate>Tue, 10 Jan 2012 19:07:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Silverlight 2 Changes</title>
		<link>http://scorbs.com/2008/10/31/silverlight-2-changes/</link>
		<comments>http://scorbs.com/2008/10/31/silverlight-2-changes/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 23:15:06 +0000</pubDate>
		<dc:creator>Karen</dc:creator>
				<category><![CDATA[silverlight]]></category>
		<category><![CDATA[spain (2008)]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[visualstatemanager]]></category>

		<guid isPermaLink="false">http://scorbs.com/2008/10/31/silverlight-2-changes</guid>
		<description><![CDATA[Between Silverlight 2 Beta 2 &#38; Silverlight 2 RTW, there were a few changes and additions.&#160; Here&#8217;s a brief rundown on the areas I directly worked on.&#160; The overall breaking change list can be found here. &#160; Control Model Silverlight &#8230; <a href="http://scorbs.com/2008/10/31/silverlight-2-changes/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p></p><br /><p>Between Silverlight 2 Beta 2 &amp; Silverlight 2 RTW, there were a few changes and additions.&nbsp; Here&#8217;s a brief rundown on the areas I directly worked on.&nbsp; </p>
<p>The overall breaking change list can be found <a href="http://blogs.msdn.com/silverlight_sdk/archive/2008/10/10/silverlight-breaking-changes-between-beta-2-and-release-updated-document.aspx" target="_blank">here</a>.</p>
<p>&nbsp;</p>
<p><strong>Control Model Silverlight 2 RTW Updates</strong></p>
<ul>
<li><u>generic.xaml lives in themes directory</u>
<ul>
<li>For WPF compat, we&#8217;re now looking for generic.xaml at \themes\resources.xaml.&nbsp; It still needs to be built as an assembly resource.</li>
</ul>
<li><u>VisualTransition.GeneratedDuration</u>
<ul>
<li>The VisualTransition.Duration&#8217;s property name has changed.&nbsp; It is now called VisualTransition.GeneratedDuration.
<li>This value will only impact the duration of <em>generated</em> transition animations.&nbsp; It has no affect on the VisualTransition.Storyboard animations.</li>
</ul>
<li><u>VisualTransition.Storyboard must be defined inline</u>
<ul>
<li>You cannot set VisualTransition.Storyboard to be a storyboard resource.&nbsp; It needs to be defined as content of the &lt;VisualTransition&gt;.</li>
</ul>
</li>
</ul>
<p><strong></strong>&nbsp;</p>
<p><strong>HTTP Networking Silverlight 2 RTW Updates</strong></p>
<ul>
<li><u>Cross-scheme HTTP &lt;-&gt; HTTPS calls are allowed with a cross domain file.</u>
<ul>
<li>See my <a href="http://scorbs.com/2008/04/05/silverlight-http-networking-stack-part-1-site-of-origin-communication">Networking Tutorial</a> for more details</li>
</ul>
<li><u>Sub-domain wildcards are allowed within a clientaccesspolicy.xml cross domain file</u>
<ul>
<li>See my <a href="http://scorbs.com/2008/04/05/silverlight-http-networking-stack-part-1-site-of-origin-communication">Networking Tutorial</a> for more details</li>
</ul>
<li><u>Setting the Content-Type is always allowed on cross domain POSTS</u>
<ul>
<li>Of course, the cross domain POST itself needs to be allowed by the service&#8217;s cross domain policy file.
<li>All other headers still need to be explicitly allowed in the service&#8217;s cross domain policy file.</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://scorbs.com/2008/10/31/silverlight-2-changes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Silverlight 2 Beta2</title>
		<link>http://scorbs.com/2008/06/10/silverlight-2-beta2/</link>
		<comments>http://scorbs.com/2008/06/10/silverlight-2-beta2/#comments</comments>
		<pubDate>Tue, 10 Jun 2008 23:44:17 +0000</pubDate>
		<dc:creator>Karen</dc:creator>
				<category><![CDATA[silverlight]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[controlmodel]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[skinning]]></category>

		<guid isPermaLink="false">http://scorbs.com/2008/06/10/silverlight-2-beta2/</guid>
		<description><![CDATA[Silverlight Beta2 is officially out in the wild!&#160; All the required download links to get started are here: Silverlight 2 Beta 2 runtime Visual Studio 2008 Silverlight Tools&#160; Expression Blend 2.5 June Preview Deep Zoom Composer &#160; Also, for the &#8230; <a href="http://scorbs.com/2008/06/10/silverlight-2-beta2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p></p><br /><p>Silverlight Beta2 is officially out in the wild!&#160; </p>
<p><a href="http://scorbs.com/wp-content/uploads/2008/06/logo.jpg"><img height="154" alt="logo" src="http://scorbs.com/wp-content/uploads/2008/06/logo-thumb.jpg" width="171" /></a> </p>
<p>All the required download links to get started are <a href="http://silverlight.net/GetStarted/">here</a>:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/vs2008/products/cc268305.aspx">Silverlight 2 Beta 2 runtime</a></li>
<li><a href="http://go.microsoft.com/fwlink/?LinkId=120319">Visual Studio 2008 Silverlight Tools</a>&#160;</li>
<li><a href="http://expression.microsoft.com/en-us/cc643423.aspx">Expression Blend 2.5 June Preview</a> </li>
<li><a href="http://go.microsoft.com/fwlink/?LinkID=120627">Deep Zoom Composer</a></li>
</ul>
<p>&#160;</p>
<p>Also, for the feature areas I drive, here are the major Beta2 updates:</p>
<p><strong>Networking</strong></p>
<ul>
<li><u>Wider API set for WebClient</u>
<ul>
<li>Upload methods for streams and strings </li>
<li>Set request headers on uploads </li>
</ul>
</li>
<li><u>Threading Updates</u>
<ul>
<li>HttpWebRequest &amp; WebClient are callable on a background thread </li>
<li>HttpWebRequest&#8217;s delegates are called on a new non-UI thread.
<ul>
<li>Delegates were previously always called on the UI thread. </li>
<li>You must invoke back on to the UI thread if the data you&#8217;re retrieving will be consumed by a UI element. </li>
<li>For an example, see the updated <a href="http://scorbs.com/2008/04/05/silverlight-http-networking-stack-part-1-site-of-origin-communication/">networking post series (part one)</a>. </li>
</ul>
</li>
</ul>
</li>
<li><u>Progressive download support</u>
<ul>
<li>When AllowReadStreamBuffering is set to false on HttpWebRequest and WebClient, the returned request stream supports progressive Stream.BeginRead() calls. </li>
</ul>
</li>
<li><u>Cross domain URI &amp; path character restrictictions</u></li>
<ul>
<li>The allowed characters in cross domain paths has been expanded to include &quot;=&quot; and &quot;;&quot;.</li>
<li>For more details, see the updated <a href="http://scorbs.com/2008/04/15/silverlight-http-networking-stack-part-2-cross-domain-communication-overview/">networking post series (part two)</a>.</li>
</ul>
<li><u>Cross domain policy files</u> </li>
<ul>
<li>Cross domain policy files do not allow you to send request headers by default.&#160; You must explicitly opt in to request headers in the policy file. </li>
<li>For more details, see this updated <a href="http://scorbs.com/2008/04/22/silverlight-http-networking-stack-part-3-configuring-a-cross-domain-policy-file/">networking post series (part three)</a>. </li>
</ul>
</ul>
<p><strong>Control Model Customization</strong></p>
<ul>
<li><u>Easier control subclassing when you don&#8217;t want to change control visuals</u>
<ul>
<li>The DefaultStyleKey property indicates the type that should be used to look up the built-in style (e.g. MyButton.DefaultStyleKey = typeof(MyButton)
<ul>
<li>The runtime looks up the generic.xaml in the assembly where the DefaultStyleKey&#8217;s Type value was defined. </li>
<li>It also uses the DefaultStyleKey to look up the built-in style w/in that generic.xaml&#8217;s ResourceDictionary </li>
</ul>
</li>
<li>DefaultStyleKey should be set in the control&#8217;s constructor </li>
<li>If you sub class Button and do not set the DefaultStyleKey, you will &quot;inherit&quot; the Button&#8217;s built-in style </li>
</ul>
</li>
<li><u>Expansion of the Parts and States model with VisualStateManager</u>
<ul>
<li>This is a big one!&#160; Look for a new post coming soon explains how we&#8217;ve made control visual state &amp; transition management easier. </li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://scorbs.com/2008/06/10/silverlight-2-beta2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Silverlight HTTP Networking Stack &#8211; Part 3 (Configuring a Cross Domain Policy File)</title>
		<link>http://scorbs.com/2008/04/22/silverlight-http-networking-stack-part-3-configuring-a-cross-domain-policy-file/</link>
		<comments>http://scorbs.com/2008/04/22/silverlight-http-networking-stack-part-3-configuring-a-cross-domain-policy-file/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 19:49:43 +0000</pubDate>
		<dc:creator>Karen</dc:creator>
				<category><![CDATA[silverlight]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[networking]]></category>

		<guid isPermaLink="false">http://scorbs.com/2008/04/22/silverlight-http-networking-stack-part-3-configuring-a-cross-domain-policy-file/</guid>
		<description><![CDATA[Here&#8217;s the final post in this 3 part Silverlight HTTP networking series. In the first post, we discussed basic site of origin HTTP communication.&#160; In the second, we gave an overview of Silverlight&#8217;s cross domain communication support. Today, we&#8217;ll drill &#8230; <a href="http://scorbs.com/2008/04/22/silverlight-http-networking-stack-part-3-configuring-a-cross-domain-policy-file/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p></p><br /><p>Here&#8217;s the final post in this 3 part Silverlight HTTP networking series. </p>
<p>In the <a href="http://scorbs.com/2008/04/05/silverlight-http-networking-stack-part-1-site-of-origin-communication">first post</a>, we discussed basic site of origin HTTP communication.&nbsp; In the <a href="http://scorbs.com/2008/04/15/silverlight-http-networking-stack-part-2-cross-domain-communication-overview/">second</a>, we gave an overview of Silverlight&#8217;s cross domain communication support. </p>
<p>Today, we&#8217;ll drill in to how to configure your web service to enable Silverlight cross domain callers.&nbsp; If you haven&#8217;t already, please be sure to read (at least) <a href="http://scorbs.com/2008/04/15/silverlight-http-networking-stack-part-2-cross-domain-communication-overview/">part 2</a> of this series &#8211; it provides a lot context for this discussion.</p>
<p><em>Note: this tutorial has been updated for Silverlight 2 RTW</em></p>
<p><em></em>&nbsp;</p>
<p>(Series Links:&nbsp; <a href="http://scorbs.com/2008/04/05/silverlight-http-networking-stack-part-1-site-of-origin-communication">Part 1</a>, <a href="http://scorbs.com/2008/04/15/silverlight-http-networking-stack-part-2-cross-domain-communication-overview/">Part 2</a>, <a href="http://scorbs.com/2008/04/22/silverlight-http-networking-stack-part-3-configuring-a-cross-domain-policy-file/">Part 3</a>)</p>
<p>&nbsp;</p>
<p><strong>So, You Want To Make Your Web Service Callable By 3rd Parties&#8230;</strong></p>
<p>Exposing your web service to 3rd parties is an important decision that should be done with care and diligence.&nbsp; As you&#8217;re designing your web service APIs, please keep the following in mind:</p>
<p><u>1. Using cookies/auth on your main site?&nbsp; Create a separate domain for your 3rd party-accessible APIs</u></p>
<p>In Silverlight, we send cookies &amp; authentication with each cross domain request.&nbsp; Because of this, web service authors need to be careful to separate their 3rd party accessible APIs from their main site.</p>
<p>Let&#8217;s look at example.&nbsp; http://cool.com uses cookie authentication.&nbsp; Once a user is logged on, she can access and update her public profile as well as her personal account information.</p>
<p>Now, http://cool.com wants to enable 3rd party apps to access public profile information.&nbsp;&nbsp; However, they don&#8217;t want to these 3rd party apps to get at a user&#8217;s billing information. </p>
<p>If the primary site and the web service is hosted on the one domain, then once a user logs in, cookies &amp; auth are sent from http://cool.com applications well as 3rd party applications.</p>
<p><img src="http://farm3.static.flickr.com/2416/2506720662_980a3e90e5.jpg"></p>
<p>This could allow 3rd party sites to access protected information on the user&#8217;s account. </p>
<p>Instead, the web service apis should be hosted on a separate domain. </p>
<p><img src="http://farm3.static.flickr.com/2375/2505890255_bbd37f48f4.jpg"></p>
<p>This way, even though cookies and auth are always sent, 3rd party applications cannot call (authenticated) web services on the main site.</p>
<p>Do you want to expose your web service to more than one partner, or to the public at large?&nbsp; If so, then basic/digest authentication and/or cookies aren&#8217;t sufficient for that web service&nbsp; authentication.&nbsp; Which leads us to&#8230;</p>
<p><u>2.&nbsp; Requiring 3rd party apps to authenticate?&nbsp; Use an in-message authentication approach.</u></p>
<p>You should not rely on cookies or basic/digest authentication to authenticate a request on a 3rd party exposed API.&nbsp; This is because multiple 3rd parties will be using the same APIs, and the same cookies and/or auth will be sent to http://api.cool.com regardless of the specific caller.</p>
<p><img src="http://farm4.static.flickr.com/3054/2399221155_6b70b3ef3d.jpg"></p>
<p>Let&#8217;s say a user trusts http://bar.com and authenticates to http://api.cool.com from http://bar.com/app.xap.&nbsp;&nbsp; That same user does NOT trust http://foo.com. </p>
<p>However, since http://api.cool.com uses cookie authentication, once the user has signed in, she is signed in for all calls from that browser session, not just a particular site.&nbsp; This means&nbsp; http://foo.com/app.xap can access private information, even though that wasn&#8217;t the user&#8217;s intent.</p>
<p>If you want to authenticate the particular application calling a web service method, it is better to use an in message authentication.&nbsp; For instance, you could specify the particular application&#8217;s key as a parameter in the query string.</p>
<p><img src="http://farm4.static.flickr.com/3120/2400054752_5b33bf4b5b.jpg"></p>
<p><em></em></p>
<p>With an in-message approach to authentication, you can determine which 3rd party application is calling your web service.</p>
<p><u>3.&nbsp; Set the cache policy on your cross domain policy file</u></p>
<p>As explained <a href="http://scorbs.com/2008/04/15/silverlight-http-networking-stack-part-2-cross-domain-communication-overview/">last time</a>, we use the browser plugin networking APIs to issue requests for the cross domain policy file.&nbsp; This means that the normal browser rules around request caching apply to the policy file.</p>
<p>We recommend that you do NOT allow the browser to cache the policy file &#8211; this makes changing the policy file at later time much easier.&nbsp; Turning off client caching is done by configuring your server to set a &#8220;Cache-Control:no-cache&#8221; response header on the policy file.</p>
<p>Remember, we only check a site&#8217;s cross domain policy once per application session, so the bandwidth/latency cost of not caching the policy file is limited.</p>
<p><u>4.&nbsp; Restrict the policy as much as possible</u></p>
<p>The last piece of advice is the easiest, but the one most prone to copy &amp; paste mistake:&nbsp; don&#8217;t open up a web service to everyone unless you *need* everyone to be able to call it.</p>
<p>If you&#8217;re just trying to enable certain particular partner apps to call your web service, allow access to that handful of domains.</p>
<p>Similarly, if you only really want public callers on a certain path, then just open up that subpath. </p>
<p>That being said, don&#8217;t configure a policy with 400 different &lt;resource&gt; tags &#8211; as that is also difficult to audit and maintain.&nbsp; As always, good security is a balance between reducing surface area and maintaining simplicity.</p>
<p>&nbsp;</p>
<p><strong>Configuring a Silverlight Policy File</strong></p>
<p>The Silverlight policy file is called clientaccesspolicy.xml.&nbsp; A Silverilght policy file that opens up an entire domain to the public &amp; allows Content-Type header to be sent looks like:</p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">&lt;?</span><span style="color: #800000">xml</span> <span style="color: #ff0000">version</span><span style="color: #0000ff">="1.0"</span> <span style="color: #ff0000">encoding</span><span style="color: #0000ff">="utf-8"</span>?<span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span
> <span style="color: #0000ff">&lt;</span><span style="color: #800000">access-policy</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">cross-domain-access</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">policy</span> <span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>       <span style="color: #0000ff">&lt;</span><span style="color: #800000">allow-from</span> <span style="color: #ff0000">http-request-headers</span><span style="color: #0000ff">="Content-Type"</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">domain</span> <span style="color: #ff0000">uri</span><span style="color: #0000ff">="*"</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>       <span style="color: #0000ff">&lt;/</span><span style="color: #800000">allow-from</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>       <span style="color: #0000ff">&lt;</span><span style="color: #800000">grant-to</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">resource</span> <span style="color: #ff0000">path</span><span style="color: #0000ff">="/"</span> <span style="color: #ff0000">include-subpaths</span><span style="color: #0000ff">="true"</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>       <span style="color: #0000ff">&lt;/</span><span style="color: #800000">grant-to</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>     <span style="color: #0000ff">&lt;/</span><span style="color: #800000">policy</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">cross-domain-access</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">access-policy</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>&nbsp; </pre>
</div>
</div>
<p><em>Specifying WHO is allowed by a policy</em></p>
<p>Within a policy, you specify allowed domains by:</p>
<ul>
<li>a specific domain&nbsp; (e.g. &#8216;http://bar.com&#8217;, &#8216;https://bar.com&#8217;) </li>
<ul>
<li>Represents only the domain with that specific protocol, host name &amp; port.</li>
</ul>
<li>subdomain wildcard (e.g. &#8216;http://*.bar.com&#8217;)
<ul>
<li>Represents all subdomains</li>
</ul>
<li>http wildcard (i.e. &#8216;http://*&#8217;) </li>
<ul>
<li>Represents all http:// domains</li>
</ul>
<li>general wildcard (i.e. &#8216;*&#8217;)</li>
<ul>
<li>Represents all domains (http:// &amp; https://), if an http service
<li>Represents all secure domains (https://), if an https service</li>
</ul>
</ul>
<p>Note: If your service is an HTTPS service, you need to explicitly allow insecure HTTP callers with the &#8216;http://*&#8217; literal.&nbsp; Otherwise, allowing &#8216;*&#8221; will only grant access to secure HTTPS callers.</p>
<p>&nbsp;</p>
<p><em>Specifying WHAT is allowed by a policy</em></p>
<p>Also, within a policy, you specify the granted resources on the server by either:</p>
<ol>
<li>Supplying a path and setting include-subpaths to be false.&nbsp; This means that only requests that <u>exactly</u> match the specified path are allowed.
<li>Supplying a path and setting include-subpaths to be true.&nbsp; This mean requests whose paths are <u>prefixed</u> by the specified path are allowed. </li>
</ol>
<p>&nbsp;</p>
<p><em>Specifying HOW a request can be sent</em></p>
<p>By default, no request headers can be sent.&nbsp; You&nbsp; can designate which request headers should be allowed on POSTs by:</p>
<ol>
<li>&#8220;*&#8221; wildcard representing all non-blacklisted headers
<li>a comma seperated list of headers (e.g. &#8220;SOAPAction, Content-Type&#8221;) </li>
</ol>
<p>It&#8217;s also possible to specify more than one policy within a policy file. </p>
<p>&nbsp;</p>
<p><em>Examples</em></p>
<p>Here are some more clientaccesspolicy.xml examples:</p>
<p><u>Example1:&nbsp; http://cool.com/clientaccesspolicy.xml:</u></p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">&lt;?</span><span style="color: #800000">xml</span> <span style="color: #ff0000">version</span><span style="color: #0000ff">="1.0"</span> <span style="color: #ff0000">encoding</span><span style="color: #0000ff">="utf-8"</span>?<span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">access-policy</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">cross-domain-access</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">policy</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>       <span style="color: #0000ff">&lt;</span><span style="color: #800000">allow-from <span style="color: #ff0000">http-request-headers</span><span style="color: #0000ff">="SOAPAction"</span></span><span style="color: #0000ff">&gt;</span>      </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">domain</span> <span style="color: #ff0000">uri</span><span style="color: #0000ff">="http://sub.cool.com/"</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">domain</span> <span style="color: #ff0000">uri</span><span style="color: #0000ff">="http://partner.com"</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">domain</span> <span style="color: #ff0000">uri</span><span style="color: #0000ff">="http://friend.com"</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>       <span style="color: #0000ff">&lt;/</span><span style="color: #800000">allow-from</span><span style="color: #0000ff">&gt;</span>      </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>       <span style="color: #0000ff">&lt;</span><span style="color: #800000">grant-to</span><span style="color: #0000ff">&gt;</span>      </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">resource</span> <span style="color: #ff0000">path</span><span style="color: #0000ff">="/shipments"</span> <span style="color: #ff0000">include-subpaths</span><span style="color: #0000ff">="true"</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  12:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">resource</span> <span style="color: #ff0000">path</span><span style="color: #0000ff">="/creditcards"</span> <span style="color: #0000ff">/&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style
="color: #606060">  13:</span>       <span style="color: #0000ff">&lt;/</span><span style="color: #800000">grant-to</span><span style="color: #0000ff">&gt;</span>      </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  14:</span>     <span style="color: #0000ff">&lt;/</span><span style="color: #800000">policy</span><span style="color: #0000ff">&gt;</span>  </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  15:</span>   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">cross-domain-access</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  16:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">access-policy</span><span style="color: #0000ff">&gt;</span></pre>
</div>
</div>
<p>The above policy allows requests coming from Silverlight applications on:</p>
<ul>
<li>http://sub.cool.com, http://partner.com, and <a href="http://friend.com">http://friend.com</a>.&nbsp; </li>
</ul>
<p>They can send on POSTs:</p>
<ul>
<li>SOAPAction request headers</li>
<li>Content-Type request headers.&nbsp; (Is allowed by default.)</li>
</ul>
<p>They have access to:</p>
<ul>
<li>http://cool.com/shipments and all its subpaths (e.g. http://cool.com/shipments/, http://cool.com/shipments/details.xml, etc).&nbsp;
<li><a href="http://cool.com/shipments/creditcards">http://cool.com/shipments/creditcards</a> </li>
</ul>
<p>&nbsp;</p>
<p>Note: The allowed domains do NOT have access to http://cool.com/creditcards/ or http://cool.com/creditcards/numbers.xml, as the &#8220;/creditcards&#8221; resource tag does not have an include-subpath=&#8221;true&#8221; attribute.</p>
<p>&nbsp;</p>
<p><u>Example2:&nbsp; http://cool.com/clientaccesspolicy.xml:</u></p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">&lt;?</span><span style="color: #800000">xml</span> <span style="color: #ff0000">version</span><span style="color: #0000ff">="1.0"</span> <span style="color: #ff0000">encoding</span><span style="color: #0000ff">="utf-8"</span>?<span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">access-policy</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">cross-domain-access</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">policy</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>       <span style="color: #0000ff">&lt;</span><span style="color: #800000">allow-from</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">domain</span> <span style="color: #ff0000">ur</span><span style="color: #0000ff">="http://sub.cool.com"</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>       <span style="color: #0000ff">&lt;/</span><span style="color: #800000">allow-from</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>       <span style="color: #0000ff">&lt;</span><span style="color: #800000">grant-to</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">resource</span> <span style="color: #ff0000">path</span><span style="color: #0000ff">="/partner/feeds/favorites.rss"</span> <span style="color: #0000ff">/&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>       <span style="color: #0000ff">&lt;/</span><span style="color: #800000">grant-to</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>     <span style="color: #0000ff">&lt;/</span><span style="color: #800000">policy</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">cross-domain-access</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">cross-domain-access</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: non
e; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">policy</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span>       <span style="color: #0000ff">&lt;</span><span style="color: #800000">allow-from</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">domain</span> <span style="color: #ff0000">ur</span><span style="color: #0000ff">="*"</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span>       <span style="color: #0000ff">&lt;/</span><span style="color: #800000">allow-from</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span>       <span style="color: #0000ff">&lt;</span><span style="color: #800000">grant-to</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">resource</span> <span style="color: #ff0000">path</span><span style="color: #0000ff">="/api"</span> <span style="color: #ff0000">include-subpaths</span><span style="color: #0000ff">="true"</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span>       <span style="color: #0000ff">&lt;/</span><span style="color: #800000">grant-to</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span>     <span style="color: #0000ff">&lt;/</span><span style="color: #800000">policy</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  22:</span>   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">cross-domain-access</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  23:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">access-policy</span><span style="color: #0000ff">&gt;</span></pre>
</div>
</div>
<p>The above policy file contains two policies.&nbsp; Requests are allowed if&#8230;</p>
<ul>
<li>they come from an app on http://sub.com.com and are requesting http://cool.com/partners/feeds/favorites.rss
<li>OR they are for any subpath of http://cool.com/api </li>
</ul>
<p>Note:&nbsp; If you&#8217;re trying to create your own policy file, <a href="http://timheuer.com">Tim Heuer</a> has written a <a href="http://timheuer.com/blog/archive/2008/04/06/silverlight-cross-domain-policy-file-snippet-intellisense.aspx ">blog post</a> that helps you get VS intellisense when authoring a clientaccesspolicy.xml.</p>
<p><strong></strong>&nbsp;</p>
<p><strong>Configuring a Silverlight-Supported Flash Policy File</strong></p>
<p>The Flash policy file is called crossdomain.xml.&nbsp; Silverlight supports crossdomain.xml files that allow public access to an entire domain.&nbsp; Specifically, this mean supporting crossdomain.xml of the format:</p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">&lt;?</span><span style="color: #800000">xml</span> <span style="color: #ff0000">version</span><span style="color: #0000ff">="1.0"</span>?<span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> <span style="color: #0000ff">&lt;!</span><span style="color: #800000">DOCTYPE</span> <span style="color: #ff0000">cross-domain-policy</span> <span style="color: #ff0000">SYSTEM</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>      <span style="color: #0000ff">"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">cross-domain-policy</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">allow-access-from</span> <span style="color: #ff0000">domain</span><span style="color: #0000ff">="*"</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">cross-domain-policy</span><span style="color: #0000ff">&gt;</span></pre>
</div>
</div>
<p><strong></strong></p>
<p><strong>So, that&#8217;s our 3 part HTTP networking series.&nbsp; Hope you found it useful.&nbsp; Like always, we love to hear your feedback.</strong></p>
<p><strong>Can&#8217;t wait to see the applications you&#8217;re going to build!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://scorbs.com/2008/04/22/silverlight-http-networking-stack-part-3-configuring-a-cross-domain-policy-file/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Silverlight HTTP Networking Stack &#8211; Part 2 (Cross Domain Communication Overview)</title>
		<link>http://scorbs.com/2008/04/15/silverlight-http-networking-stack-part-2-cross-domain-communication-overview/</link>
		<comments>http://scorbs.com/2008/04/15/silverlight-http-networking-stack-part-2-cross-domain-communication-overview/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 16:49:38 +0000</pubDate>
		<dc:creator>Karen</dc:creator>
				<category><![CDATA[silverlight]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[networking]]></category>

		<guid isPermaLink="false">http://scorbs.com/2008/04/15/silverlight-http-networking-stack-part-2-cross-domain-communication-overview/</guid>
		<description><![CDATA[In part 1, we discussed how Silverlight applications talk to their site of origin server.  In this post, we&#8217;ll dive into the high level concepts around Silverlight&#8217;s cross domain HTTP communication.  Then next time, we&#8217;ll go into details of how &#8230; <a href="http://scorbs.com/2008/04/15/silverlight-http-networking-stack-part-2-cross-domain-communication-overview/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p></p><br /><p>In <a href="http://scorbs.com/2008/04/05/silverlight-http-networking-stack-part-1-site-of-origin-communication">part 1</a>, we discussed how Silverlight applications talk to their site of origin server.  In this post, we&#8217;ll dive into the high level concepts around Silverlight&#8217;s cross domain HTTP communication.  Then <a href="http://scorbs.com/2008/04/22/silverlight-http-networking-stack-part-3-configuring-a-cross-domain-policy-file/">next time</a>, we&#8217;ll go into details of how to set up a cross domain policy file.</p>
<p><em>Note: this tutorial has been updated for Silverlight 2 RTW.</em></p>
<p>(Series Links:  <a href="http://scorbs.com/2008/04/05/silverlight-http-networking-stack-part-1-site-of-origin-communication">Part 1</a>, <a href="http://scorbs.com/2008/04/15/silverlight-http-networking-stack-part-2-cross-domain-communication-overview/">Part 2</a>, <a href="http://scorbs.com/2008/04/22/silverlight-http-networking-stack-part-3-configuring-a-cross-domain-policy-file/">Part 3</a>)</p>
<p><em></em></p>
<p><strong>What is Cross Domain Communication?</strong></p>
<p>As mentioned last time, your Silverlight application by default can only talk back to its site of origin server.  This is in line with the general browser sandbox, and is designed to prevent <a href="http://en.wikipedia.org/wiki/Cross-site_request_forgery">cross site forgery</a>.</p>
<p><img src="http://farm3.static.flickr.com/2390/2399977896_0fa786f311.jpg" alt="" /></p>
<p>The site of origin server is determined by the app&#8217;s deployment URI: the location of the XAP for managed applications, the address of the XAML page for javascript applications.</p>
<p>If a HTTP request matches the origin server&#8217;s domain, protocol, and port number, then it&#8217;s considered a site of origin request and is allowed.  Otherwise, it&#8217;s classified as a cross domain call.</p>
<p><strong>Silverlight&#8217;s Cross Domain Policy Support</strong></p>
<p>In order for a cross domain request to a particular web service to succeed, that web service needs to explicitly opt-in to 3rd party callers.</p>
<p>In Silverlight 2, the primary way of enabling cross domain calls is through a policy file placed at the root of the server.  We support two types of policy files:</p>
<ol>
<li>Silverlight Cross Domain Policy File (clientaccesspolicy.xml)</li>
<li>(A subset of the) Flash Cross Domain Policy File (crossdomain.xml)</li>
</ol>
<p><img src="http://farm3.static.flickr.com/2108/2399977934_12f6a21cbc.jpg" alt="" /></p>
<p><strong>What Can You Say to a Cross Domain Server?</strong></p>
<p><em>Basic Capabilities</em></p>
<p>So, you&#8217;ve got permission from the appropriate policy file to make a cross domain request .  What can you do with that request?</p>
<ul>
<li>Scheme:  HTTP and HTTPS    (file:// and other protocols are not supported)</li>
<li>Verb support:  GET &amp; POST</li>
<li>Status codes:  200 (OK) or 404 (NotFound) only</li>
</ul>
<p><em>Request Headers</em></p>
<p>By default, only Content-Type request headers are allowed to be sent.  A policy file can explicitly opt in to setting certain headers.  There is also a set of blacklist headers that can never be sent.</p>
<p>Request headers can only be sent on POSTs, not GETs.</p>
<p><em>Cookies &amp; Authentication</em></p>
<p>All the requests you send will have have <span style="text-decoration: underline;">cookies and authentication sent</span> with them.  This is a significant point, and we&#8217;ll dig into it deeper in the part 3 of this post series.</p>
<p>The above capabilities are determined by the browser plugin&#8217;s networking APIs.  Please see <a href="http://scorbs.com/2008/04/05/silverlight-http-networking-stack-part-1-site-of-origin-communication/">Part 1</a> for a deeper discussion of networking stack implementation.</p>
<p><em>Path Character Restrictions</em></p>
<p>Silverlight has placed certain restrictions on the path portion of a cross domain URI.</p>
<p><img src="http://farm3.static.flickr.com/2393/2401969044_396af18a24.jpg" alt="" /> Specifically, a cross domain request path CANNOT contain:</p>
<ul>
<li>&#8220;..&#8221;    (consecutive dots)</li>
<li>&#8220;./&#8221;    (dot and a forward slash)</li>
<li>&#8220;%&#8221;    (percent sign, thus preventing %-encoding)</li>
</ul>
<p>This restriction was done to prevent attacks around path manipulation and %-encoded path manipulation, which malicious apps could use to try to escape out of an allowed path into a disallowed path.</p>
<p><strong>Where does Silverlight Look for the Cross Domain Policy File?</strong></p>
<p>When a request is detected as a cross domain request, we look first for a Silverlight policy file at the root of the request&#8217;s server.</p>
<div>
<table border="1" cellspacing="0" cellpadding="2" width="527" align="center">
<tbody>
<tr>
<td width="217" valign="top"><em>Request URI</em></td>
<td width="308" valign="top"><em>Policy File Checked</em></td>
</tr>
<tr>
<td width="218" valign="top"><span style="text-decoration: underline;">http://foo.com</span>/bar/data</td>
<td width="308" valign="top"><span style="text-decoration: underline;">http://foo.com</span>/clientaccesspolicy.xml</td>
</tr>
<tr>
<td width="218" valign="top"><span style="text-decoration: underline;">http://sub.foo.com</span>/bar/data</td>
<td width="308" valign="top"><span style="text-decoration: underline;">http://sub.foo.com</span>/clientaccesspolicy.xml</td>
</tr>
<tr>
<td width="218" valign="top"><span style="text-decoration: underline;">http://foo.com:8080</span>/bar/data</td>
<td width="308" valign="top"><span style="text-decoration: underline;">http://foo.com:8080</span>/clientaccesspolicy.xml</td>
</tr>
</tbody>
</table>
</div>
<p>If such a clientaccesspolicy.xml file does not exist or is malformed, we then look for a crossdomain.xml file at the same location.</p>
<p><em>&#8220;Caching&#8221; Of Policy Files</em></p>
<p>Silverlight looks up the cross domain policy file for a particular server ONCE per application session.  (Where an application session is the lifetime of a particular xap or xaml page instance in memory.)</p>
<p>Also, we use the browser networking stack to issue the request for the policy file, so the normal browser caching of the request happens under the covers.</p>
<p><em>Redirects</em></p>
<p>Redirects for the policy file itself are not allowed.</p>
<p>Request URIs redirects will only be successful if the original and final URIs are allowed via the appropriate cross domain policy.  (Note:  The browser handles handles the actual redirect logic itself and ensures it matches <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">w3 spec</a>.)</p>
<p><strong>So that&#8217;s the high level cross domain behavior overview.  Next time, we&#8217;ll drill into how to set up a cross domain policy file.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://scorbs.com/2008/04/15/silverlight-http-networking-stack-part-2-cross-domain-communication-overview/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Silverlight HTTP Networking Stack – Part 1 (Site of Origin Communication)</title>
		<link>http://scorbs.com/2008/04/05/silverlight-http-networking-stack-part-1-site-of-origin-communication/</link>
		<comments>http://scorbs.com/2008/04/05/silverlight-http-networking-stack-part-1-site-of-origin-communication/#comments</comments>
		<pubDate>Sat, 05 Apr 2008 17:05:44 +0000</pubDate>
		<dc:creator>Karen</dc:creator>
				<category><![CDATA[silverlight]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[networking]]></category>

		<guid isPermaLink="false">http://scorbs.com/2008/04/05/silverlight-http-networking-stack-part-1-site-of-origin-communication/</guid>
		<description><![CDATA[This is going to be a three parter.&#160; :)&#160; Today, we’ll dig into the core networking capabilities of the HTTP stack for site of origin communication.&#160; In the next two parts, we’ll go deep into understanding our HTTP cross domain &#8230; <a href="http://scorbs.com/2008/04/05/silverlight-http-networking-stack-part-1-site-of-origin-communication/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p></p><br /><p>This is going to be a three parter.&nbsp; :)&nbsp; Today, we’ll dig into the core networking capabilities of the HTTP stack for site of origin communication.&nbsp; In the next two parts, we’ll go deep into understanding our HTTP cross domain support.</p>
<p><em>Note: this tutorial has been updated for Silverlight 2 RTW.</em></p>
<p>(Series Links:&nbsp; <a href="http://scorbs.com/2008/04/05/silverlight-http-networking-stack-part-1-site-of-origin-communication">Part 1</a>, <a href="http://scorbs.com/2008/04/15/silverlight-http-networking-stack-part-2-cross-domain-communication-overview/">Part 2</a>, <a href="http://scorbs.com/2008/04/22/silverlight-http-networking-stack-part-3-configuring-a-cross-domain-policy-file/">Part 3</a>)</p>
<p>&nbsp;</p>
<p><b>So, You Want To Phone Home…</b></p>
<p>In Silverlight 2, by default, you are only able to talk back to your site of origin server.&nbsp; This is in line with the general browser sandbox, and is designed to prevent <a href="http://en.wikipedia.org/wiki/Cross-site_request_forgery">cross site forgery</a>.</p>
<p><img src="http://farm4.static.flickr.com/3237/2389139084_946e798ec3.jpg"></p>
<p>To determine if a HTTP request is going back to site of origin, we look at the deployment URI of the XAP and the request URI.&nbsp; Comparing these two URIs, 3 things must match:</p>
<ol>
<li><u>Same domain</u>. http://foo.com&nbsp; is different than http://bar.foo.com or http://www.foo.com
<li><u>Same protocol</u>.<strong> </strong>http://foo.com is different than https://foo.com
<li><u>Same port</u>. http://foo.com is different than http://foo.com:8080 </li>
</ol>
<p>If all three things match, the request will be allowed to go out into the world.&nbsp; If they don’t, by default, we’ll disallow the request and throw an exception.&nbsp; (Cross domain policies will be covered in part 2 of this post series.)</p>
<p><b></b></p>
<p><b>What Can You Say to Your Site of Origin Server?</b></p>
<p>You can talk to your site of origin server with the below capabilities:</p>
<ul>
<li>Verb support:&nbsp; GET &amp; POST
<li>Request header support:&nbsp; Most standard &amp; custom headers
<li>Status codes:&nbsp; 200 (OK) or 404 (NotFound) only </li>
</ul>
<p>Also, all the requests you send will have the “right thing happen” to them from a cookies and authentication standpoint.&nbsp; This is a result of us leveraging the hosting browser to make the HTTP request.</p>
<p>HTTP requests themselves are:</p>
<ul>
<li>Asynchronous only </li>
</ul>
<p><b></b></p>
<p><b>Why Those Capabilities?</b></p>
<p>The above capabilities are the result of:</p>
<ul>
<li>Requirements for basic web services
<li>Restrictions in the underlying browser plug-in networking APIs </li>
</ul>
<p>To implement our Silverlight HTTP stack, we use the browser plug-in&#8217;s networking APIs.&nbsp; The HTTP capabilities we expose are therefore bound by the common set of capabilities exposed by the browsers that Silverlight supports.</p>
<p>Note:&nbsp; There are other ways we could have implemented the networking stack.&nbsp; For instance, we could have proxied all calls through the browser’s XmlHttpRequest object.&nbsp; However, this would have imposed a site of origin restriction on the requests, and we wanted to enable cross domain communication to existing web services.&nbsp; Similarly, we could have gone directly to the operating system’s networking APIs, but then we would have lost the cookies and authentication integration with the browser.&nbsp; In the future, exploring multiple of these stacks to expose more capabilities is definitely a possibility, and is something we would like feedback on.</p>
<p><b></b></p>
<p><b>What APIs Should I Use?</b></p>
<p>There are two APIs in Silverlight for HTTP communication.&nbsp; The first is WebClient and the second is HttpWebRequest.</p>
<p><i><strong>WebClient</strong></i></p>
<p><a href="http://msdn2.microsoft.com/en-us/library/system.net.httpwebresponse(VS.95).aspx">WebClient</a> is a great API with a simple, events-based paradigm.&nbsp; You can use it to easily download or upload a strings and Streams.</p>
<p>For a download, WebClient does a GET request and then gives you back the result in the form you wanted.&nbsp; For an upload, WebClient does a POST and sends the data you passed it. It also automatically resolves relative URIs against the deployment URI of the XAP.</p>
<p><em>Sample: Downloading a string using WebClient</em></p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">private</span> <span style="color: #0000ff">void</span> DownloadString()</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     WebClient webClient = <span style="color: #0000ff">new</span> WebClient();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>&nbsp; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>     <span style="color: #008000">// Hook up events</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     webClient.DownloadProgressChanged += <span style="color: #0000ff">new</span> DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>     webClient.DownloadStringC
ompleted += <span style="color: #0000ff">new</span> DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>&nbsp; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>     <span style="color: #008000">// Initiate download</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>     webClient.DownloadStringAsync(<span style="color: #0000ff">new</span> Uri(<span style="color: #006080">"myfeed.xml"</span>, UriKind.Relative));</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>&nbsp; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span> <span style="color: #0000ff">void</span> webClient_DownloadProgressChanged(<span style="color: #0000ff">object</span> sender, DownloadProgressChangedEventArgs e)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span>     <span style="color: #008000">// Update progress UI</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>     progressTextBox.Text = e.ProgressPercentage;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span>&nbsp; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span> <span style="color: #0000ff">void</span> webClient_DownloadStringCompleted(<span style="color: #0000ff">object</span> sender, DownloadStringCompletedEventArgs e)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span>     <span style="color: #0000ff">if</span> (e.Error == <span style="color: #0000ff">null</span>)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  22:</span>     {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  23:</span>         <span style="color: #008000">// Clear progress UI and show downloaded string</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  24:</span>         progressTextBox.Text = <span style="color: #006080">""</span>;</pre>
<pre style="padding-right: 0px; p
adding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  25:</span>         feedTextBox.Text = e.Result;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  26:</span>     }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  27:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  28:</span>&nbsp; </pre>
</div>
<p><i><strong></strong></i></p>
</div>
<p><i><strong></strong></i></p>
<p><i><strong>HttpWebRequest &amp; HttpWebResponse</strong></i></p>
<p><a href="http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest%28VS.95%29.aspx">HttpWebRequest</a> and <a href="http://msdn2.microsoft.com/en-us/library/system.net.httpwebresponse(VS.95).aspx">HttpWebResponse</a> are the standard .NET HTTP apis.&nbsp; They are much more powerful than WebClient but also more complex to use.</p>
<p><em>Sample:&nbsp; Sending POST request using HttpWebRequest</em></p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> SynchronizationContext syncContext;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>&nbsp; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span> <span style="color: #0000ff">private</span> <span style="color: #0000ff">void</span> Page_Loaded(<span style="color: #0000ff">object</span> sender, EventArgs e)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>     <span style="color: #008000">// Grab SynchronizationContext while on UI Thread</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     syncContext = SynchronizationContext.Current;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>  </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>    <span style="color: #008000">// Create request</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>     HttpWebRequest request = WebRequest.Create(<span style="color: #006080">"http://msite.com/myFeed"</span>) <span style="color: #0000ff">as</span> HttpWebRequest;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>     request.Method = <span style="color: #006080">"POST"</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>     request.Headers[<span style="color: #006080">"x-custom-header"</span>] = <span style="color: #006080">"value"</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>&nbsp; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>     <span style="color: #008000">// Make async call for request stream.  Callback will be called on a background thread.</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>     IAsyncResult asyncResult = </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span>              request.BeginGetRequestStream(<span style="color: #0000ff">new</span> AsyncCallback(RequestStreamCallback), request);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; ove
rflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span>&nbsp; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span> <span style="color: #0000ff">private</span> <span style="color: #0000ff">void</span> RequestStreamCallback(IAsyncResult ar)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span>     HttpWebRequest request = ar.AsyncState <span style="color: #0000ff">as</span> HttpWebRequest;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span>     Request.ContentType = <span style="color: #006080">"text/xml"</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  22:</span>     Stream requestStream = request.EndGetRequestStream(ar);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  23:</span>     StreamWriter streamWriter = <span style="color: #0000ff">new</span> StreamWriter(requestStream);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  24:</span>     streamWriter.Encoding = Encoding.UTF8;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  25:</span>     streamWriter.Write(<span style="color: #006080">"&lt;?xml version="1.0"?&gt;"</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  26:</span>                        + <span style="color: #006080">"&lt;entry xmlns="http://www.w3.org/2005/Atom"&gt;"</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  27:</span>                        + <span style="color: #006080">"&lt;author&gt;"</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  28:</span>                        + <span style="color: #006080">"&lt;name&gt;Elizabeth Bennet&lt;/name&gt;"</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  29:</span>                        + <span style="color: #006080">"&lt;email&gt;liz@gmail.com&lt;/email&gt;"</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  30:</span>                        + <span style="color: #006080">"&lt;/author&gt;"</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  31:</span>                        + <span style="color: #006080">"&lt;title type="text"&gt;Entry 1&lt;/title&gt;"</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  32:</span>                        + <span style="color: #006080">"&lt;content type="text"&gt;This is my entry&lt;/content&gt;"</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: no
ne; background-color: white; border-bottom-style: none"><span style="color: #606060">  33:</span>                        + <span style="color: #006080">"&lt;/entry&gt;"</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  34:</span>                                                                       </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  35:</span>     streamWriter.Close();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  36:</span>&nbsp; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  37:</span>    <span style="color: #008000">// Make async call for response.  Callback will be called on a background thread.</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  38:</span>     request.BeginGetResponse(<span style="color: #0000ff">new</span> AsyncCallback(ResponseCallback), request);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  39:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  40:</span> <span style="color: #0000ff">private</span> <span style="color: #0000ff">void</span> ResponseCallback(IAsyncResult ar)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  41:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  42:</span>     HttpWebRequest request = ar.AsyncState <span style="color: #0000ff">as</span> HttpWebRequest;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  43:</span>     WebResponse response = request.EndGetResponse(ar);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  44:</span>&nbsp; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  45:</span>     <span style="color: #008000">// Invoke onto UI thread</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  46:</span>     syncContext.Post(ExtractResponse, response);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  47:</span>&nbsp; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  48:</span>     <span style="color: #008000">// use response.  Could include reading response stream.</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  49:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  50:</span>&nbsp; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padd
ing-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  51:</span> <span style="color: #0000ff">private</span> <span style="color: #0000ff">void</span> ExtractResponse(<span style="color: #0000ff">object</span> state)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  52:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  53:</span>     HttpWebResponse response = state <span style="color: #0000ff">as</span> HttpWebResponse;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  54:</span>     <span style="color: #008000">// use response.  Could include reading response stream.</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  55:</span> }</pre>
</div>
</div>
<p><b></b></p>
<p><b>Feedback – We Love It</b></p>
<p>Do the capabilities of our HTTP stack satisfy your needs?&nbsp; What do you think of the API set?&nbsp; We’d love to hear your thoughts.</p>
<p><b>Stay Tuned for Cross Domain Support in Part 2….</b></p>
]]></content:encoded>
			<wfw:commentRss>http://scorbs.com/2008/04/05/silverlight-http-networking-stack-part-1-site-of-origin-communication/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
	</channel>
</rss>

