<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">Network Class Library Team (System.Net)</title><subtitle type="html" /><id>http://blogs.msdn.com/b/ncl/atom.aspx</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/ncl/" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/b/ncl/atom.aspx" /><generator uri="http://telligent.com" version="5.6.50428.7875">Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><updated>2009-05-05T22:06:00Z</updated><entry><title>New Picture Hunt Silverlight Socket Sample</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/ncl/archive/2011/04/28/new-silverlight-socket-sample.aspx" /><id>http://blogs.msdn.com/b/ncl/archive/2011/04/28/new-silverlight-socket-sample.aspx</id><published>2011-04-27T23:42:00Z</published><updated>2011-04-27T23:42:00Z</updated><content type="html">&lt;p&gt;Introducing “Picture Hunt”, the newest Silverlight sample app.&amp;#160; This multiplayer game demonstrates the power of the System.Net Socket API inside a browser.&amp;#160; No more long-polls, or trying to turn HTML requests into something that’s almost a socket; you can use sockets directly!&amp;#160; The sample is also a “good network citizen”.&amp;#160; It shows the network status nicely, without any irritating pop-ups; it automatically tries to reconnect, and it will automatically switch networks as needed. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-06-62-metablogapi/2705.PictureHunt_5F00_43710652.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="PictureHunt" border="0" alt="PictureHunt" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-06-62-metablogapi/0726.PictureHunt_5F00_thumb_5F00_19AD8B5F.png" width="403" height="303" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Check out the &lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-06-62-metablogapi/3312.PictureHunt_5F00_Sample_5F00_25A2303D.pptx" target="_self"&gt;Powerpoint deck&lt;/a&gt; that goes into detail about the demo and complete &lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-06-62-metablogapi/0654.PictureHunt_5F00_1139903B.zip" target="_self"&gt;source code&lt;/a&gt; for the whole demo, including the game server, pictures, and the Silverlight Policy server.&lt;/p&gt;  &lt;p&gt;The sample is on &lt;a href="http://channel9.msdn.com/Shows/SilverlightTV/Silverlight-TV-70-Sockets-Unplugged"&gt;Silverlight TV&lt;/a&gt;!&amp;#160; An earlier version of the game (without the fancy animations) is on Silverlight TV on Channel 9 on MSDN.&amp;#160; The discussion includes when to use sockets (answer: when you need to send and receive any time, not just when you’re polling, or when you need to match an existing protocol, or when you need to reduce your server resources), plus tips on how to get started, and common issues with network programming.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10158877" width="1" height="1"&gt;</content><author><name>Peter Smith in Redmond</name><uri>http://blogs.msdn.com/PeSmith/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Silverlight 4 Socket Policy Changes</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/ncl/archive/2010/04/15/silverlight-4-socket-policy-changes.aspx" /><id>http://blogs.msdn.com/b/ncl/archive/2010/04/15/silverlight-4-socket-policy-changes.aspx</id><published>2010-04-15T21:57:00Z</published><updated>2010-04-15T21:57:00Z</updated><content type="html">&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;After installing the Silverlight plugin,&amp;nbsp;a Silverlight application&amp;nbsp;is able to run on your computer without your explicit consent whenever you browse to a webpage which links to it.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Because there is no explicit user action required to run, Silverlight applications are executed within what is known as a security sandbox – a locked-down environment which prevents a malicious application from doing anything to attack your computer or your local network.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;For the &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/system.net.sockets.socket(VS.95).aspx"&gt;&lt;FONT size=3 face=Calibri&gt;Socket&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; and &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/system.net.sockets.udpsinglesourcemulticastclient(VS.96).aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;UDP multicast client&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; classes, this sandboxing takes the form of a required &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/cc645032(VS.95).aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;policy check&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt; which the application must pass before being able to communicate with network resources.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;While these policy checks prevent a malicious application from attacking your computer or other devices on your local network, they also pose a barrier to deploying legitimate Silverlight applications.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In order to make it easier to write and deploy Silverlight applications which communicate using Sockets and the UDP multicast clients, a number of changes have been made to the policy systems for Silverlight 4.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;Elevated Trust&lt;/B&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Silverlight 4 introduces the notion of &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/ee721083(VS.96).aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;Elevated Trust&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt; applications.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Using this feature, an out-of-browser Silverlight application can indicate to the user that it wants to run in Elevated Trust while it is being installed for out-of-browser use.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If the user consents, the application is run within an expanded sandbox which allows it to do things that a normal Silverlight application is explicitly denied the ability to do for security reasons.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;In Silverlight 4, Elevated Trust applications have been given permission to use the Socket and UDP multicast client classes without policy checks.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The Socket class may be used to create a TCP connection to any port on any host without the need for a cross-domain policy file.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Similarly, the UDP multicast clients may join any multicast group on any port greater than or equal to 1024 without the need for a policy responder to authorize it.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;No extra API calls are needed in order to take advantage of this work; the existing APIs light up with the extra functionality when an app is running in Elevated Trust.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In-browser and non-elevated out-of-browser applications still have the same policy check requirements as before, and will continue to throw a &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/system.net.sockets.socketexception(VS.96).aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;SocketException&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; with the &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/system.net.sockets.socketexception.socketerrorcode(v=VS.96).aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;SocketErrorCode&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt; property set to SocketError.AccessDenied if the policy check fails.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;Socket Policy via HTTP&lt;/B&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;When running in the browser sandbox, the policy check for the Socket class requires downloading a policy file from the intended target that controls which Silverlight applications are allowed to connect to it.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In previous versions of Silverlight, this download&amp;nbsp;was conducted using a custom &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/cc645032(v=VS.95).aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;protocol&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt; running on TCP port 943.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;While this protocol can be implemented in a very lightweight and easily-secured fashion on the server side, it requires running a dedicated service and opening port 943 in any firewalls between the client and server.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;In Silverlight 4, applications using the Socket class may opt in to retrieving the policy file via the HTTP protocol (on TCP port 80) instead of the custom TCP protocol.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This allows servers which are already running HTTP services to authorize Socket connections from Silverlight apps without having to deploy a new service on the machine or open up additional firewall surface.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;To toggle this behavior, set the new &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/system.net.sockets.socketasynceventargs.socketclientaccesspolicyprotocol(v=VS.95).aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;SocketAsyncEventArgs.SocketClientAccessPolicyProtocol&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; property on the SocketAsyncEventArgs passed to &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/bb538102(VS.95).aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;Socket.ConnectAsync&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; to &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/system.net.sockets.socketclientaccesspolicyprotocol(VS.96).aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;SocketClientAccessPolicyProtocol.Http&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;When this option is set, the Socket class will attempt to download the policy file using an HTTP GET request for http://[target ip address]/clientaccesspolicy.xml.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It will NOT attempt to download the policy via the custom TCP protocol if the policy check fails.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The path of the Uri (/clientaccesspolicy.xml) is the same as that used by the &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest(VS.95).aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;HttpWebRequest&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; class for its &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/cc645032(VS.95).aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;policy check&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The two policies may be combined into a single file; the Socket class will safely ignore any &amp;lt;resource&amp;gt; elements, and the HttpWebRequest class will safely ignore any &amp;lt;socket-resource&amp;gt; elements.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Unlike the HttpWebRequest class, the Socket class always specifies the target IP address as the host when retrieving the policy file, even if the connection is made to a DnsEndpoint.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This prevents confusion in the case of a single machine hosting websites from multiple domains.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;As a result, the server must be configured to respond to requests made to its IP address in addition to requests made to a specific hostname.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9996891" width="1" height="1"&gt;</content><author><name>Aaron Oneal</name><uri>http://blogs.msdn.com/Aaron-Oneal-_5B00_MSFT_5D00_/ProfileUrlRedirect.ashx</uri></author><category term="Sockets" scheme="http://blogs.msdn.com/b/ncl/archive/tags/Sockets/" /><category term="Silverlight" scheme="http://blogs.msdn.com/b/ncl/archive/tags/Silverlight/" /></entry><entry><title>System.Uri FAQ</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/ncl/archive/2010/02/23/system-uri-f-a-q.aspx" /><id>http://blogs.msdn.com/b/ncl/archive/2010/02/23/system-uri-f-a-q.aspx</id><published>2010-02-23T23:04:00Z</published><updated>2010-02-23T23:04:00Z</updated><content type="html">&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;NCL includes classes for networking related technology such as the base type System.Uri.&amp;nbsp; URI’s are used extensively to identify network resources, especially on the Internet.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We’ve found that different customers frequently ask us the same questions about System.Uri and its capabilities, so we would like to share some of those questions with you here.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;For space reasons we will address some of the harder questions in an additional post about System.Uri Customization.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT size=4&gt;&lt;FONT face=Cambria&gt;1. System.Uri vs. Strings&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H2&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Q. If a URI is just a simple string of characters, why do you need the System.Uri type at all?&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;A. A URI is a string of characters, but it is not necessarily simple.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;For example, take the following URI: &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.5in" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;HTTPS://basicUser:password@www.xn--fek.COM:443/path/../realpath/./&lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: 'MS Gothic'; mso-bidi-font-family: 'MS Gothic'"&gt;ル&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;/my-App.Aspx?QueryParam1=value1;param2=value2#document_Fragment &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;There are a number of public standards that outline the syntax for URIs.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;System.Uri’s role is to validate the given string is in the appropriate syntax, as well as to provide easy access to the subcomponents.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Microsoft took this seriously enough to add a series of Code Analysis rules in Visual Studio to discourage developers from storing URIs as Strings.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;See: http://msdn.microsoft.com/en-us/library/ms182174.aspx&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT size=4&gt;&lt;FONT face=Cambria&gt;2. Standards and History&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H2&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Q. What public standards does System.Uri support?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Has this changed in newer versions of the .NET framework?&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;A. When the System.Uri class was first introduced in .NET 1.0, it implemented the public standards described in RFCs 1736, 1738, and 2396, along with other functionality necessary for a base type in the .NET Framework.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Since then, these standards have been updated or modified by new standards introduced in RFCs 3490, 3986, 3987, and others.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In .NET 3.5 System.Uri was expanded to add support for RFCs 3490 and 3987 as described in question 10 below.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In order to maintain backwards compatibility very few changes have ever been made to migrate System.Uri from RFC 2396 to 3986.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT size=4&gt;&lt;FONT face=Cambria&gt;3. URI Components&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H2&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;Q.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Which System.Uri properties give me which components of my URI?&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;A.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Here are some of the common properties, along with the (canonicalized) data they represent from the previous sample URI.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;See RFCs 2396 and 3986 for more details on the component definitions.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Note: IRI and IDN are enabled for these samples (see question 10).&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;TABLE style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; MARGIN: auto auto auto 32.25pt; BORDER-COLLAPSE: collapse; BORDER-TOP: medium none; BORDER-RIGHT: medium none; mso-padding-alt: 0in 5.75pt 0in 5.75pt; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184" class=MsoTableGrid border=1 cellSpacing=0 cellPadding=0 class="MsoTableGrid"&gt;
&lt;TBODY&gt;
&lt;TR style="HEIGHT: 13.55pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 99.6pt; PADDING-RIGHT: 5.75pt; HEIGHT: 13.55pt; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt" vAlign=top width=133&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;Property/Method&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 327.75pt; PADDING-RIGHT: 5.75pt; HEIGHT: 13.55pt; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" vAlign=top width=437&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;Result&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 13.55pt; mso-yfti-irow: 1"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 99.6pt; PADDING-RIGHT: 5.75pt; HEIGHT: 13.55pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=133&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;OriginalString&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 327.75pt; PADDING-RIGHT: 5.75pt; HEIGHT: 13.55pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=437&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;HTTPS://basicUser:password@www.xn--fek.COM:443/path/../realpath/./&lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: 'MS Gothic'; mso-bidi-font-family: 'MS Gothic'"&gt;ル&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;/my-App.Aspx?QueryParam1=value1;param2=value2#document_Fragment&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 13.55pt; mso-yfti-irow: 2"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 99.6pt; PADDING-RIGHT: 5.75pt; HEIGHT: 13.55pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=133&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;Scheme&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 327.75pt; PADDING-RIGHT: 5.75pt; HEIGHT: 13.55pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=437&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;https&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 13.55pt; mso-yfti-irow: 3"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 99.6pt; PADDING-RIGHT: 5.75pt; HEIGHT: 13.55pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=133&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;UserInfo&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 327.75pt; PADDING-RIGHT: 5.75pt; HEIGHT: 13.55pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=437&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;basicUser:password&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 12.8pt; mso-yfti-irow: 4"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 99.6pt; PADDING-RIGHT: 5.75pt; HEIGHT: 12.8pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=133&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;Host&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 327.75pt; PADDING-RIGHT: 5.75pt; HEIGHT: 12.8pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=437&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;www.&lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: 'MS Gothic'; mso-bidi-font-family: 'MS Gothic'"&gt;ル&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;.com&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 12.8pt; mso-yfti-irow: 5"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 99.6pt; PADDING-RIGHT: 5.75pt; HEIGHT: 12.8pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=133&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;DnsSafeHost&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 327.75pt; PADDING-RIGHT: 5.75pt; HEIGHT: 12.8pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=437&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;www.xn--fek.COM&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 13.55pt; mso-yfti-irow: 6"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 99.6pt; PADDING-RIGHT: 5.75pt; HEIGHT: 13.55pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=133&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;Port&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 327.75pt; PADDING-RIGHT: 5.75pt; HEIGHT: 13.55pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=437&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;443&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 12.8pt; mso-yfti-irow: 7"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 99.6pt; PADDING-RIGHT: 5.75pt; HEIGHT: 12.8pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=133&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;Authority*&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 327.75pt; PADDING-RIGHT: 5.75pt; HEIGHT: 12.8pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=437&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;www.&lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: 'MS Gothic'; mso-bidi-font-family: 'MS Gothic'"&gt;ル&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;.com (+ ‘:’ + Port, for non-default ports)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 13.55pt; mso-yfti-irow: 8"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 99.6pt; PADDING-RIGHT: 5.75pt; HEIGHT: 13.55pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=133&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;&lt;SPAN style="mso-no-proof: yes"&gt;AbsolutePath&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 327.75pt; PADDING-RIGHT: 5.75pt; HEIGHT: 13.55pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=437&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;/realpath/%E3%83%AB/my-App.Aspx&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 13.55pt; mso-yfti-irow: 9"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 99.6pt; PADDING-RIGHT: 5.75pt; HEIGHT: 13.55pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=133&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;Query&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 327.75pt; PADDING-RIGHT: 5.75pt; HEIGHT: 13.55pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=437&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;?QueryParam1=value1;param2=value2&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 13.55pt; mso-yfti-irow: 10"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 99.6pt; PADDING-RIGHT: 5.75pt; HEIGHT: 13.55pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=133&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;Fragment&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 327.75pt; PADDING-RIGHT: 5.75pt; HEIGHT: 13.55pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=437&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;#document_Fragment&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 13.55pt; mso-yfti-irow: 11"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 99.6pt; PADDING-RIGHT: 5.75pt; HEIGHT: 13.55pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=133&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;AbsoluteUri&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 327.75pt; PADDING-RIGHT: 5.75pt; HEIGHT: 13.55pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=437&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;https://basicUser:password@www.&lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: 'MS Gothic'; mso-bidi-font-family: 'MS Gothic'"&gt;ル&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;.com/realpath/%E3%83%AB/my-App.Aspx?QueryParam1=value1;param2=value2#document_Fragment&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 13.55pt; mso-yfti-irow: 12; mso-yfti-lastrow: yes"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 99.6pt; PADDING-RIGHT: 5.75pt; HEIGHT: 13.55pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=133&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;ToString()&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.75pt; WIDTH: 327.75pt; PADDING-RIGHT: 5.75pt; HEIGHT: 13.55pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=437&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;https://basicUser:password@www.&lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: 'MS Gothic'; mso-bidi-font-family: 'MS Gothic'"&gt;ル&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;.com/realpath/&lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: 'MS Gothic'; mso-bidi-font-family: 'MS Gothic'"&gt;ル&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;/my-App.Aspx?QueryParam1=value1;p&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;aram2=value2#document_Fragment&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.5in" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;* The RFC’s indicate that Authority can optionally include UserInfo.&amp;nbsp;&amp;nbsp; To enhance security and limit the exposure of user credentials, System.Uri does not include UserInfo in the Authority.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT size=4&gt;&lt;FONT face=Cambria&gt;4. Canonicalization&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H2&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;Q.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Why don’t I get back exactly what I put in?&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;A.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;According to the RFCs, some URI components may be accepted in not-quite-standard formats as long as they are converted to standard formats.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This process is called &lt;I style="mso-bidi-font-style: normal"&gt;canonicalization&lt;/I&gt; or &lt;I style="mso-bidi-font-style: normal"&gt;normalization&lt;/I&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Examples of such are that the scheme and host should be lower case, default port values should be dropped, and dot segments in the path should be compressed.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Additionally, System.Uri expands IPv6 addresses to their longest form.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;All of these processes are required to facilitate equivalency checking when accessing resources and verifying security access.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT size=4&gt;&lt;FONT face=Cambria&gt;5. Uri Manipulation&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H2&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;Q. Why can’t I change any of System.Uri’s properties?&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;A.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This is because System.Uri is an immutable base type, the same as System.String.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You couldn’t trust System.Uri as a base type if anybody could change its contents underneath you.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;To conveniently remove, change out, or assemble components of a URI use the System.UriBuilder class, or System.UriTemplate.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Also see the relative Uri APIs; Uri.MakeRelativeUri, and a System.Uri constructor.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT size=4&gt;&lt;FONT face=Cambria&gt;6. Supported Schemes&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H2&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;Q. What schemes does System.Uri support?&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;A.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;System.Uri has built in parsing rules for Http, Https, File, Ftp, Gopher, MailTo, NetPipe, NetTcp, News, Nntp, Uuid, as well as generic parsing rules applied to unrecognized schemes.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Here are some samples for each of these schemes.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;TABLE style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; BORDER-COLLAPSE: collapse; BORDER-TOP: medium none; BORDER-RIGHT: medium none; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184" class=MsoTableGrid border=1 cellSpacing=0 cellPadding=0 class="MsoTableGrid"&gt;
&lt;TBODY&gt;
&lt;TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt" vAlign=top width=638&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;http://user:password@host:80/path/file.txt?Query#fragment&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 1"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=638&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;https://user:password@host:443/path/file.txt?Query#fragment&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 2"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=638&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;ftp://user:password@host:21/path/file.txt#fragment&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 3"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=638&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;file://host/path/file.txt?Query#fragment&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 4"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=638&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;c:\path\file.txt&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;(implicit DOS file)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 5"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=638&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;\\host\share\path\file.txt&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;(implicit UNC file)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 6"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=638&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;gopher://user:password@host:70/path/file.txt#fragment&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 7"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=638&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;news:///path/file.txt#fragment&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 8"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=638&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;nntp://user:password@host:119/path/file.txt#fragment&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 9"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=638&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;telnet://user:password@host:23/path/file.txt#fragment&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 10"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=638&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;ldap://user:password@host:389/path/file.txt?Query#fragment&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 11"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=638&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;mailto:user:password@host:25/path/file.txt?Query#fragment&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 12"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=638&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;net.pipe://host/path/file.txt?Query#fragment&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 13"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=638&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;net.tcp://host:808/path/file.txt?Query#fragment&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 14; mso-yfti-lastrow: yes"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=638&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;uuid:///path/file.txt#fragment&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;H2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT size=4&gt;&lt;FONT face=Cambria&gt;7. UriFormatExceptions &amp;amp; Validating User Input &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H2&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;Q.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Do I have to try/catch UriFormatExceptions every time I create a new System.Uri?&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;A.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Not always. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;In .NET 3.5 we added the System.Uri.TryCreate methods so you can check for problems with your data input without all the hassle and performance problems of try/catch blocks and exception handling.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;Uri&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt; result = &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (!&lt;SPAN style="COLOR: #2b91af"&gt;Uri&lt;/SPAN&gt;.TryCreate(userUriString, &lt;SPAN style="COLOR: #2b91af"&gt;UriKind&lt;/SPAN&gt;.Absolute, &lt;SPAN style="COLOR: blue"&gt;out&lt;/SPAN&gt; result))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// Fail gracefully, ask the user to try again.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The down side here is that when a URI fails to parse, these methods do not return an error message explaining what was wrong with the input.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If you need to display the error message then you should still use the try/catch pattern.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT size=4&gt;&lt;FONT face=Cambria&gt;8. MailTo Multiple E-mail Addresses&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H2&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Q. Why doesn’t System.Uri’s MailTo scheme support multiple e-mail addresses?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;A.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;System.Uri supports RFC 1738 which only allows for a single e-mail address in the Authority of a MailTo URI.&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;An alternative way to represent multiple e-mail addresses with one System.Uri is by using query parameters as discussed in RFC 2368.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The following example works well with Microsoft Outlook:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.5in" class=MsoNormal&gt;&lt;A href="mailto:jim@contoso.com?cc=test@contoso.com;billy@contoso.com&amp;amp;bcc=sally@contoso.com&amp;amp;subject=High%20there&amp;amp;to=boby@contoso.com" mce_href="mailto:jim@contoso.com?cc=test@contoso.com;billy@contoso.com&amp;amp;bcc=sally@contoso.com&amp;amp;subject=High%20there&amp;amp;to=boby@contoso.com"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;mailto:jim@contoso.com?cc=test@contoso.com;billy@contoso.com&amp;amp;bcc=sally@contoso.com&amp;amp;subject=High%20there&amp;amp;to=boby@contoso.com&lt;/FONT&gt;&lt;/A&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;The only caveat with this format is that Outlook will only populate the To field with the primary e-mail address (&lt;/FONT&gt;&lt;A href="mailto:jim@contoso.com" mce_href="mailto:jim@contoso.com"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;jim@contoso.com&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt;); Any To field data in the query (&lt;/FONT&gt;&lt;A href="mailto:boby@contoso.com" mce_href="mailto:boby@contoso.com"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;boby@contoso.com&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt; ) is ignored.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Other e-mail application’s behaviors may vary.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Alternatively, if you need to parse out multiple e-mail addresses from a data string, you can use the System.Net.Mail.MailAddressCollection class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;If you have access to a mail server, you may also consider adding all of the addresses to a mailing list. Then you only need a single address (&lt;/FONT&gt;&lt;A href="mailto:MyGroup@constoso.com" mce_href="mailto:MyGroup@constoso.com"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;mailto:MyGroup@constoso.com&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;), and the lists membership can be updated without changing this address.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT size=4&gt;&lt;FONT face=Cambria&gt;9. Implicit Dos/Unc File Paths&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H2&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;Q.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Why can’t I put # in my &lt;SPAN style="mso-field-code: ' HYPERLINK '"&gt;&lt;SPAN class=MsoHyperlink&gt;&lt;U&gt;&lt;FONT color=#0000ff&gt;file:///&lt;/FONT&gt;&lt;/U&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; URI path?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It’s a valid file name character!&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;A.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In a standard URI, the # symbol identifies the start of the Fragment portion.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Because this may conflict with local file paths, System.Uri treats # differently for implicit Dos and Unc file paths.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;TABLE style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; MARGIN: auto auto auto 27.9pt; BORDER-COLLAPSE: collapse; BORDER-TOP: medium none; BORDER-RIGHT: medium none; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184" class=MsoTableGrid border=1 cellSpacing=0 cellPadding=0 class="MsoTableGrid"&gt;
&lt;TBODY&gt;
&lt;TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 35.35pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt" vAlign=top width=47&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 199.3pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" vAlign=top width=266&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Explicit&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 183.85pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" vAlign=top width=245&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Implicit&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 1"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 35.35pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=47&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Dos&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 199.3pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=266&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;file:///c:/path/file.txt#Fragment&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 183.85pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=245&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;c:\path\file#name.txt&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 2; mso-yfti-lastrow: yes"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 35.35pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=47&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Unc&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 199.3pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=266&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;file://server/share/path/file.txt#Fragment&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 183.85pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=245&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;\\server\share\path\file#name.txt&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;As shown in the table, explicit file URIs are allowed to have fragments, so the # symbol is not considered part of the file path for the LocalPath or AbsolutePath properties.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Implicit file URIs cannot have fragments, so the # symbol remains part of the path.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT size=4&gt;&lt;FONT face=Cambria&gt;10. Unicode, IRI, and IDN&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H2&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;Q. Why does System.Uri turn my Unicode into xn--fek or %E3%83%AB?&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;A.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Many computer programs and protocols do not yet understand non-Latin/ASCII character sets, so System.Uri has implemented RFC defined logic for encoding and decoding these non-Latin Unicode characters.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This support was significantly expanded in .NET 3.5 to include the IDN and IRI RFC standards described below.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;For backwards compatibility reasons these new behaviors can only be enabled through configuration file settings.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;See the System.Uri documentation for details.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;RFC 3490 outlines International Domain Names (IDNs).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This standard covers the encoding of non-Latin Unicode characters in the Host portion of a URI.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This encoding is designed for backwards compatibility with existing DNS standards and implementations.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The Uri.DnsSafeHost property was extended to show this new format.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;RFC 3987 introduces Internationalized Resource Identifiers (IRIs).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This standard discusses how to encode non-Latin Unicode characters outside of the Host portion of a URI.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Use the Uri.AbsoluteUri property rather than Uri.ToString() to get this encoding.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H1 style="MARGIN: 24pt 0in 0pt"&gt;&lt;FONT size=5&gt;&lt;FONT face=Cambria&gt;Conclusion&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H1&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;As you can see System.Uri is a powerful tool that helps you handle a large variety of complex URI syntaxes.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In a following post we will address how you can expand System.Uri’s support for additional syntaxes through customization.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9968361" width="1" height="1"&gt;</content><author><name>Tratcher</name><uri>http://blogs.msdn.com/chrross/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>UDP Multicast in Silverlight 4</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/ncl/archive/2009/11/18/udp-multicast-in-silverlight-4.aspx" /><id>http://blogs.msdn.com/b/ncl/archive/2009/11/18/udp-multicast-in-silverlight-4.aspx</id><published>2009-11-18T22:40:00Z</published><updated>2009-11-18T22:40:00Z</updated><content type="html">&lt;P&gt;In Silverlight 4, we have added multicast support. If you’re not familiar with multicast, here’s a quick scenario to explain what it is and why it might be useful to you.&lt;/P&gt;
&lt;H4&gt;Scenario Overview&lt;/H4&gt;
&lt;P&gt;Suppose your company provides market data and you need to distribute the same commodity and value records to 50,000 client workstations. It would be quite a load on the server and network infrastructure to do this in the traditional client/server TCP model where all 50,000 clients connect to the server to receive the data feed in round-robin fashion.&lt;/P&gt;
&lt;P&gt;Wouldn’t it be great if the server could just send the data once and let the network infrastructure pass it on to all subscribers in an efficient manner? That would take the load off the server since it would only be sending out the data once instead of 50,000 times. Conveniently, that’s precisely how multicast works, and this makes it a useful technique for video and content distribution. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4&gt;User Datagram Protocol (UDP)&lt;/H4&gt;
&lt;P&gt;&lt;A href="http://en.wikipedia.org/wiki/User_Datagram_Protocol" mce_href="http://en.wikipedia.org/wiki/User_Datagram_Protocol"&gt;User Datagram Protocol (UDP)&lt;/A&gt; supports multicast and is the most common low-level protocol for &lt;A href="http://en.wikipedia.org/wiki/IP_multicast" mce_href="http://en.wikipedia.org/wiki/IP_multicast"&gt;IP multicast&lt;/A&gt;. Because it’s so low-level, there are some key things you should be aware of:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;UDP by nature is not “reliable” like TCP. This means messages are not guaranteed to be received in order or at all. There are, however, forms of &lt;A href="http://en.wikipedia.org/wiki/Reliable_multicast" mce_href="http://en.wikipedia.org/wiki/Reliable_multicast"&gt;reliable multicast&lt;/A&gt;, such as &lt;A href="http://en.wikipedia.org/wiki/Pragmatic_General_Multicast" mce_href="http://en.wikipedia.org/wiki/Pragmatic_General_Multicast"&gt;Pragmatic General Multicast (PGM)&lt;/A&gt; which can be implemented on top of UDP. &lt;/LI&gt;
&lt;LI&gt;UDP has no built in &lt;A href="http://en.wikipedia.org/wiki/IP_address_spoofing" mce_href="http://en.wikipedia.org/wiki/IP_address_spoofing"&gt;IP address spoofing&lt;/A&gt; protection. Just because a message indicates it came from a particular IP address, you can’t be sure it did, so your application protocol needs to implement this protection if you need to be sure of the origin of your messages. &lt;/LI&gt;&lt;/UL&gt;
&lt;H4&gt;Multicast Concepts&lt;/H4&gt;
&lt;P&gt;&lt;STRONG&gt;Multicast Groups and Addresses&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;People are most familiar with unicast addresses, which are used to direct packets to a single host. Alternatively, a special &lt;A href="http://en.wikipedia.org/wiki/Multicast_address" mce_href="http://en.wikipedia.org/wiki/Multicast_address"&gt;multicast address&lt;/A&gt; can be used to deliver a packet to a group of destinations; specifically, all nodes which have explicitly joined the multicast group as identified by the multicast address. The 224.0.0.0/4 IPv4 and ff00::/8 IPv6 address ranges have been reserved for identifying multicast groups.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Joining a Multicast Group&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;When a computer or device wants to join a multicast group, it performs a special exchange with its router using the &lt;A href="http://en.wikipedia.org/wiki/Internet_Group_Management_Protocol" mce_href="http://en.wikipedia.org/wiki/Internet_Group_Management_Protocol"&gt;Internet Group Management Protocol (IGMP)&lt;/A&gt; or the &lt;A href="http://en.wikipedia.org/wiki/Multicast_Listener_Discovery" mce_href="http://en.wikipedia.org/wiki/Multicast_Listener_Discovery"&gt;Multicast Listener Discovery (MLD)&lt;/A&gt; protocol. This lets the router know the computer is interested in receiving traffic from the multicast group. To leverage multicast, it must be supported by the router and not otherwise blocked.&lt;/P&gt;
&lt;P&gt;Multicast is often deployed within corporate networks for efficient transmission of video. Be aware that it is common for corporate firewalls to block multicast traffic at the edge so that it cannot traverse the boundary of the corporate network. Many home ISPs enforce similar restrictions. &lt;/P&gt;
&lt;P&gt;It’s also worth mentioning that there are multiple versions of IGMP and MLD, but the specifics of negotiation are up to the client OS stack and the first-hop router; it’s not something your application needs to worry about.&lt;/P&gt;
&lt;P&gt;Finally, in addition to joining a multicast group, a complementary operation to leave the group is also available.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Multicast Sources&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The node or nodes sending data to the group are known as multicast sources. There are two common forms of IP multicast differentiated by the number of sources in the group:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Single Source Multicast / Source Specific Multicast (SSM) – A single, well-known source identified by a unicast IP address will send to the group (one-to-many). &lt;/LI&gt;
&lt;LI&gt;Any Source Multicast (ASM) – Any member of the group may behave as a multicast source and transmit data to the group (many-to-many). &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;In the case of any source multicast, additional operations are provided to block and unblock specific sources so that messages can be filtered by source address. One of the benefits of SSM is that with a single source known ahead of time, the multicast tree can be built more efficiently when nodes join the group.&lt;/P&gt;
&lt;H4&gt;New APIs&lt;/H4&gt;
&lt;P&gt;In correlation to the multicast forms above, two new classes have been introduced to the System.Net.Sockets namespace, &lt;STRONG&gt;UdpSingleSourceMulticastClient&lt;/STRONG&gt; and &lt;STRONG&gt;UdpAnySourceMulticastClient&lt;/STRONG&gt;. If you’re familiar with Sockets or UdpClient in the .NET Framework, the available operations should look very familiar to you. Here are some brief, simplified samples to demonstrate the basics.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Construction&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;// Construct a client for the multicast group 224.0.0.1 port 3000 &lt;BR&gt;// Note that only ports &amp;gt;= 1024 are supported for Silverlight &lt;BR&gt;var client = new UdpAnySourceMulticastClient(IPAddress.Parse(“224.0.0.1”), 3000); &lt;BR&gt;&lt;BR&gt;&lt;STRONG&gt;Join Group &lt;BR&gt;&lt;/STRONG&gt;&lt;BR&gt;// Join the multicast group &lt;BR&gt;client.BeginJoinGroup((result) =&amp;gt; EndJoinGroup(result), null);&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Message Receive &lt;BR&gt;&lt;/STRONG&gt;&lt;BR&gt;// Receive a message &lt;BR&gt;client.BeginReceiveFromGroup(buffer, offset, count, &lt;BR&gt;&amp;nbsp; (result) =&amp;gt; { messageLength = EndReceiveFromGroup(result, sourceAddress); }, null);&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Leave Group and Dispose&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;// Leave the group and cleanup connections &lt;BR&gt;client.Dispose();&lt;/P&gt;
&lt;P&gt;In a real application, the async calls would be chained together. For a more detailed example showing this, see SilverChat on &lt;A href="http://code.msdn.microsoft.com/silverlightsdk" mce_href="http://code.msdn.microsoft.com/silverlightsdk"&gt;MSDN Code Gallery&lt;/A&gt;.&lt;/P&gt;
&lt;H4&gt;Browser Security&lt;/H4&gt;
&lt;P&gt;Because multicast in corporate environments is often blocked at the edge, Silverlight should not be able to circumvent that trust model by allowing code from an untrusted domain to run unchecked within the corporate network where it could potentially receive and forward privileged data. To prevent this, Silverlight requires that a Silverlight Multicast Policy Responder join the multicast group to authorize Silverlight clients. If multicast has been blocked at the corporate edge, then only a service behind the corporate firewall will be able to authorize Silverlight clients, thus maintaining the original network boundary.&lt;/P&gt;
&lt;P&gt;You are free to deploy the responder in any way you choose, whether on the same or separate machine as your multicast source.&lt;/P&gt;
&lt;P&gt;For details of the policy protocol used and to review a sample implementation, please see the Silverlight Multicast Policy Responder sample also on &lt;A href="http://code.msdn.microsoft.com/silverlightsdk" mce_href="http://code.msdn.microsoft.com/silverlightsdk"&gt;MSDN Code Gallery&lt;/A&gt;.&lt;/P&gt;
&lt;H4&gt;Conclusion&lt;/H4&gt;
&lt;P&gt;This article covered how multicast can be used to reduce server and network infrastructure load, the new APIs added in Silverlight 4 to support these features, the special requirements to maintain browser security, and finally, some important points to consider for your application protocols built on UDP. Please let us know if you have questions about these new features. In addition to blog comments, you may also direct inquiries to the &lt;A href="http://social.msdn.microsoft.com/Forums/en-US/ncl/threads/" mce_href="http://social.msdn.microsoft.com/Forums/en-US/ncl/threads/"&gt;forum&lt;/A&gt;.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9910206" width="1" height="1"&gt;</content><author><name>Aaron Oneal</name><uri>http://blogs.msdn.com/Aaron-Oneal-_5B00_MSFT_5D00_/ProfileUrlRedirect.ashx</uri></author><category term="Silverlight" scheme="http://blogs.msdn.com/b/ncl/archive/tags/Silverlight/" /><category term="UDP" scheme="http://blogs.msdn.com/b/ncl/archive/tags/UDP/" /><category term="Multicast" scheme="http://blogs.msdn.com/b/ncl/archive/tags/Multicast/" /></entry><entry><title>New Performance Counters for HttpWebRequest</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/ncl/archive/2009/08/07/new-performance-counters-for-httpwebrequest.aspx" /><id>http://blogs.msdn.com/b/ncl/archive/2009/08/07/new-performance-counters-for-httpwebrequest.aspx</id><published>2009-08-08T06:56:00Z</published><updated>2009-08-08T06:56:00Z</updated><content type="html">&lt;P&gt;Performance counters!&amp;nbsp; You can never get enough!&amp;nbsp; And starting with the .NET version 4.0 Beta 2, we in the System.Net team have added six new counters to the old set.&amp;nbsp; But before we begin, some ground rules:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Performance counters have to be enabled in your application’s .config file.&amp;nbsp; I’ve put a sample of my config file at the end of this post. &lt;/LI&gt;
&lt;LI&gt;The new counters need the .NET version 4 Beta 2 runtime. &lt;/LI&gt;
&lt;LI&gt;The counters are now called “.NET CLR Networking 4.0.0.0” (the version number is new).&amp;nbsp; You only get the new performance counters when you run using the .NET version 4 CLR.&amp;nbsp; If your program runs using an older CLR, it will use the older performance counters. &lt;/LI&gt;
&lt;LI&gt;The counters are now initialized on a separate thread.&amp;nbsp; This means that for the first small amount of time, activity isn’t recorded by the performance monitor. &lt;BR&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Without any further delay, let’s take a look at the new counters.&amp;nbsp; &lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;The first two performance counters let you know that your application is running smoothly.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;1.&amp;nbsp;&amp;nbsp;&amp;nbsp; HttpWebRequests Created/Sec &lt;BR&gt;2.&amp;nbsp;&amp;nbsp;&amp;nbsp; HttpWebRequests Average Lifetime&lt;/P&gt;
&lt;P&gt;The ‘Created/Sec’ is just what it says: it’s updated whenever an HttpWebRequest is created. The performance counter takes care of adjusting the raw numbers into a “per sample interval” – just beware that the label says “per second” but it’s really “per performance counter sample time interval”.&amp;nbsp; It turns out that the default sample interval is one second, and the label is much shorter when we just call it “/Sec”.&lt;/P&gt;
&lt;P&gt;You can see the effects of this adjustment for yourself – make a program that creates a fixed number of HttpWebRequests per second.&amp;nbsp; When the performance monitor is set to “Sample every 1 seconds”, it gives that amount.&amp;nbsp; Set it to “Sample every 2 seconds” and the number doubles.&lt;/P&gt;
&lt;P&gt;But watch out!&amp;nbsp; System.Net will make HttpWebRequest objects for you – in particular, the System.Net automatic proxy detection on Windows XP will create an HttpWebRequest internally to resolve your proxy.&amp;nbsp; System.Net will also make extra objects for tunneling through proxies.&amp;nbsp; It’s even possible for FTP requests to silently make HttpWebRequests.&amp;nbsp; Exactly when we make these extra objects can change from one release to the next. &lt;/P&gt;
&lt;P&gt;The average lifetime is a little sneakier.&amp;nbsp; It’s the lifetime of the entire HTTP transaction, starting when the HttpWebRequest is created all the way until the resulting HttpWebResponse is closed.&amp;nbsp; If you ever see this counter stuck at zero even though you’re making requests and getting replies, it’s probably because you haven’t closed your HttpWebResponse!&amp;nbsp; The ‘average’ is the average for the last performance sample interval, so it’s just for the time in the “Sample every ___ seconds” option in the Performance Monitor properties box.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;There are two performance counters to look for Queuing issues.&amp;nbsp; &lt;/STRONG&gt;The .NET framework doesn’t let you (by default) send lots of requests to a server all at once.&amp;nbsp; Instead, only up to ‘ConnectionLimit’ requests can be active at once (by default, this is two); after that we put the request onto a queue.&amp;nbsp; Thanks to pipelining, a request can be ‘waiting’ without being ‘queued’. This happens when you make a request, and there’s a perfectly good connection to the server ready to be used, but it’s busy with another request.&amp;nbsp; The new request will be pipelined with an earlier request and not queued (but it still has to wait for the earlier request to end).&lt;/P&gt;
&lt;P&gt;The connection limit is trickier than you might realize because HttpWebRequests that are bound for different places but which share the same proxy share the same ServicePoint and therefore share the same set of connections.&lt;/P&gt;
&lt;P&gt;The Queue performance counters are: &lt;BR&gt;3.&amp;nbsp;&amp;nbsp;&amp;nbsp; HttpWebRequests Queued/Sec &lt;BR&gt;4.&amp;nbsp;&amp;nbsp;&amp;nbsp; HttpWebRequests Average Queue Time&lt;/P&gt;
&lt;P&gt;The Queued/Sec counter is updated whenever an item is put onto the queue; the Average Queue Time is updated whenever an item is removed from the queue.&amp;nbsp; This means that it’s possible to see items being added to the queue like crazy even though the average queue time is zero – it could just mean that the server is slow and nothing is coming off of the queue.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Lastly, there are two counters to tell if your requests aren’t completing correctly. &lt;BR&gt;&lt;/STRONG&gt;5.&amp;nbsp;&amp;nbsp;&amp;nbsp; HttpWebRequests Aborted/Sec &lt;BR&gt;6.&amp;nbsp;&amp;nbsp;&amp;nbsp; HttpWebRequests Failed/Sec&lt;/P&gt;
&lt;P&gt;A request is Aborted when the ‘Abort()’ method is called.&amp;nbsp; The Abort() method is automatically called by System.Net in some cases, all having to do with failures – when the request times out, for example, or sometimes when the request handler code triggers an exception.&amp;nbsp; Your application code can also call Abort() on a request.&lt;/P&gt;
&lt;P&gt;The most common reason that a request is Failed is that the final server response is a “could not fulfill your request.”&amp;nbsp; For example, a server reply code of 404 Not Found is a failure.&amp;nbsp; Technically speaking, the failed counter is updated when a request triggers an exception (other than exceptions thrown in your application code).&amp;nbsp; This is a good definition of failed because all of the failed server codes will throw a WebException.&amp;nbsp; Server codes that are not final – for example, a 401 Unauthorized return code will usually result in the System.Net code automatically retrying with proper credentials.&amp;nbsp; In this case, the 401 Unauthorized is not final and does not trigger an exception. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;That’s a lot: how about a diagram? &lt;BR&gt;&lt;/STRONG&gt;Certainly!&amp;nbsp; Here’s a diagram that our developer created to help understand what all of the timings are.&amp;nbsp; Each of the seven green circles represents one of the six performance counters (there are two ‘5’ items because 5 is the average lifetime, and there are two code paths that will affect that counter).&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/ncl/WindowsLiveWriter/NewPerformanceCountersforHttpWebRequest_DFEA/Diagram_2.png" mce_href="http://blogs.msdn.com/blogfiles/ncl/WindowsLiveWriter/NewPerformanceCountersforHttpWebRequest_DFEA/Diagram_2.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=Diagram border=0 alt=Diagram src="http://blogs.msdn.com/blogfiles/ncl/WindowsLiveWriter/NewPerformanceCountersforHttpWebRequest_DFEA/Diagram_thumb.png" width=540 height=371 mce_src="http://blogs.msdn.com/blogfiles/ncl/WindowsLiveWriter/NewPerformanceCountersforHttpWebRequest_DFEA/Diagram_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;As promised, here’s a sample of my config file:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The performanceCounters value is documented on MSDN at &lt;A href="http://msdn.microsoft.com/en-us/library/ms229151.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms229151.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms229151.aspx&lt;/A&gt;. &lt;BR&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;?&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt"&gt;xml&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt"&gt;version&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;"&lt;SPAN style="COLOR: blue"&gt;1.0&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;encoding&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;utf-8&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; ?&amp;gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt"&gt;configuration&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt"&gt;system.net&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt"&gt;settings&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt"&gt;performanceCounters&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt"&gt;enabled&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;/&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt"&gt;settings&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt"&gt;system.net&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt"&gt;configuration&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;I also had to add in a “requiredRuntime” to my .config file: &amp;lt;startup&amp;gt;&amp;lt;requiredRuntime version="v4.0" /&amp;gt;&amp;lt;/startup&amp;gt;.&amp;nbsp; Otherwise, my application – which I compiled with an older compiler – wouldn’t use the 4.0 CLR. &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9860753" width="1" height="1"&gt;</content><author><name>Peter Smith in Redmond</name><uri>http://blogs.msdn.com/PeSmith/ProfileUrlRedirect.ashx</uri></author><category term="Troubleshooting" scheme="http://blogs.msdn.com/b/ncl/archive/tags/Troubleshooting/" /><category term="HTTP" scheme="http://blogs.msdn.com/b/ncl/archive/tags/HTTP/" /><category term=".NET Framework 4.0" scheme="http://blogs.msdn.com/b/ncl/archive/tags/-NET+Framework+4-0/" /></entry><entry><title>What's new in System.Net.Mail</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/ncl/archive/2009/08/06/what-s-new-in-system-net-mail.aspx" /><id>http://blogs.msdn.com/b/ncl/archive/2009/08/06/what-s-new-in-system-net-mail.aspx</id><published>2009-08-06T23:10:00Z</published><updated>2009-08-06T23:10:00Z</updated><content type="html">&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;What’s new in System.Net.Mail&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;We’ve made a number of enhancements to our SMTP support for .NET 4.0, mostly in the area of Unicode support and increased standards compliance, which is an important aspect in ensuring that legitimate emails do not get flagged as spam, as well as a few other useful features.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In this post I’ll go over these enhancements and what they mean to you as a developer.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Decreased likelihood of being accidentally flagged as spam&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Many spammers don’t bother to follow the SMTP protocol correctly in sending their spam, so standards violations tend to be a major factor in calculating spam scores.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In .NET 4.0, we’ve made some significant improvements in how we encode headers and fold long lines of text in order to better comply with the SMTP protocol to reduce the likelihood that your legitimate emails will accidentally be caught by an overzealous spam filter.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You don’t need to change a thing in your code to take advantage of this since it’s all internal to System.Net.Mail.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Increased Unicode support&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;You can now include Unicode in your custom headers thanks to a new property to the &lt;B style="mso-bidi-font-weight: normal"&gt;MailMessage&lt;/B&gt; class called &lt;B style="mso-bidi-font-weight: normal"&gt;HeadersEncoding&lt;/B&gt;, which allows you to specify what Unicode encoding that custom headers are using so that they can be sent correctly (the default is UTF-8). &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;HeadersEncoding&lt;/B&gt; only affects custom headers that you add; the subject, body, and email address display names can have different encodings that are controlled by other properties in the &lt;B style="mso-bidi-font-weight: normal"&gt;MailMessage&lt;/B&gt; and &lt;B style="mso-bidi-font-weight: normal"&gt;MailAddress&lt;/B&gt; classes.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Clarification on setting header values&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;While &lt;B style="mso-bidi-font-weight: normal"&gt;MailMessage&lt;/B&gt; allows you direct access to the headers collection some headers being malformed could cause the email message to become corrupted.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The following is a list of headers that you should not set via the headers collection; any values you set for these headers will be silently discarded or overwritten when the message is sent (use the appropriate properties of &lt;B style="mso-bidi-font-weight: normal"&gt;MailMessage&lt;/B&gt; to control these headers):&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Bcc, Cc, Content-ID, Content-Location, Content-Transfer-Encoding, Content-Type, Date, From, Importance, MIME-Version, Priority, Reply-To, Sender, Subject, To, X-Priority&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Note: if you do not specify an X-Sender header, we will create one for you however we will not overwrite an X-Sender that you set.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Multiple Reply-To addresses with the new property ReplyToList&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;We’ve added another new property to &lt;B style="mso-bidi-font-weight: normal"&gt;MailMessage&lt;/B&gt; called &lt;B style="mso-bidi-font-weight: normal"&gt;ReplyToList&lt;/B&gt; that allows you to add multiple Reply-To addresses to an email.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The &lt;B style="mso-bidi-font-weight: normal"&gt;ReplyTo&lt;/B&gt; property has been obsoleted.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Content Disposition time zones&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;We’ve received some feedback on how &lt;B style="mso-bidi-font-weight: normal"&gt;ContentDisposition&lt;/B&gt; does not allow you to specify time zones in the character formats dictated by RFC 822, such as “GMT” or “PST.”&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This functionality was actually obsolete by RFC 2822, which replaces RFC 822, and dictates that an email time should always contain the offset for a timezone (e.g. “-0800” or “+0000”).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;However, we will now accept RFC 822 time zone formats and convert them to their semantically equivalent offsets.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Whenever we are unable to determine the correct semantically equivalent offset, it is converted to “-0000” meaning that the time zone is unknown.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This affects strings passed to the constructor or &lt;STRONG&gt;Parameters&lt;/STRONG&gt; collection of &lt;B style="mso-bidi-font-weight: normal"&gt;ContentDisposition&lt;/B&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Mail Address formats&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;We’ve improved our ability to parse email address strings in the &lt;B style="mso-bidi-font-weight: normal"&gt;MailAddress&lt;/B&gt; class.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Display names that contain Unicode cases and quoted local parts in the address will now be accepted correctly in most circumstances.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If an address does contain an invalid character, the exception message will inform you of what character was invalid.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Remember, you should format your email addresses as “displayname” &amp;lt;local@domain&amp;gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Authentication&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Some legacy clients do not advertise their AUTH mechanisms correctly.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Normally, in the EHLO reply you would expect to see something like AUTH LOGIN NTLM advertising that this server supports LOGIN and NTLM authentication.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Some legacy servers will instead reply with AUTH=LOGIN NTLM which is a violation of the RFC, however we have added support to &lt;B style="mso-bidi-font-weight: normal"&gt;SmtpClient&lt;/B&gt; for these legacy servers so authentication will work correctly should you encounter one.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;We hope that you find this new and improved functionality useful for your applications and, as always, feel free to drop us a line if you have any feedback on these features or anything else you would like to see!&lt;/FONT&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9859555" width="1" height="1"&gt;</content><author><name>jetucker</name><uri>http://blogs.msdn.com/jetucker/ProfileUrlRedirect.ashx</uri></author><category term="New Features" scheme="http://blogs.msdn.com/b/ncl/archive/tags/New+Features/" /><category term=".NET Framework 4.0" scheme="http://blogs.msdn.com/b/ncl/archive/tags/-NET+Framework+4-0/" /><category term="SMTP" scheme="http://blogs.msdn.com/b/ncl/archive/tags/SMTP/" /><category term="System.Net.Mail" scheme="http://blogs.msdn.com/b/ncl/archive/tags/System-Net-Mail/" /></entry><entry><title>End-to-end connectivity with NAT traversal</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/ncl/archive/2009/07/27/end-to-end-connectivity-with-nat-traversal-.aspx" /><id>http://blogs.msdn.com/b/ncl/archive/2009/07/27/end-to-end-connectivity-with-nat-traversal-.aspx</id><published>2009-07-27T21:35:00Z</published><updated>2009-07-27T21:35:00Z</updated><content type="html">&lt;p&gt;Like street numbers for a house, the Internet was originally designed so that all network devices could be directly addressed. Every connected device was given at least one unique identifier, or IP address, which could be used to route network packets to and from the device. For a while this worked well and devices had end-to-end connectivity.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/IPv4"&gt;IPv4 addresses&lt;/a&gt; can be used to route to about 4 billion (2&lt;sup&gt;32&lt;/sup&gt;) devices, but the rapid growth of the Internet quickly exhausted that available real estate. In the late 1980’s, several methods were developed to conserve this rapidly dwindling address space. Network isolation became a key strategy in this effort, and it had a beneficial side-effect – increased security. If an attacker was unable to address a device to directly establish connectivity, then attacking it was more difficult.&lt;/p&gt;  &lt;h4&gt;Home Routers with NAT&lt;/h4&gt;  &lt;p&gt;A common means for achieving this network isolation in the home is through an IPv4 router which supports &lt;a href="http://en.wikipedia.org/wiki/Network_address_translation"&gt;Network Address Translation (NAT)&lt;/a&gt;. These devices do some useful things for you:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;They pick up a single, public IPv4 address from your Internet provider &lt;/li&gt;    &lt;li&gt;They hand out IPv4 addresses to devices on your local network, most often through &lt;a href="http://en.wikipedia.org/wiki/Dhcp"&gt;DHCP&lt;/a&gt;, drawing from a pool of the IPv4 address space reserved for private networks &lt;/li&gt;    &lt;li&gt;They allow all of the devices on your network to share the single, public IPv4 address received from your Internet provider and handle the translation automatically from private to public address in conjunction with &lt;a href="http://en.wikipedia.org/wiki/TCP_and_UDP_port"&gt;port&lt;/a&gt; information &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;The following diagram illustrates this kind of deployment for two private networks both connected to the Internet through a NAT.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/ncl/WindowsLiveWriter/NATTraversalusingIPv6andTeredo_15147/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/ncl/WindowsLiveWriter/NATTraversalusingIPv6andTeredo_15147/image_thumb.png" width="520" height="221" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;With these features also come limitations. Note how both networks share the same private address space, both routers have the same 192.168.1.1 private IP address, and two different computers each have the same 192.168.1.20 private IP address. Devices on each private network can communicate within their own network, but how can they communicate with each other over the Internet?&lt;/p&gt;  &lt;p&gt;Internet packets are routed using public addresses, and in the scenario above, each network only has one public IPv4 address. That means all packets go to the home router and it figures out whether to send them on to a device on the home network.&lt;/p&gt;  &lt;p&gt;Here are 3 common strategies for achieving this routing between public and private networks:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;strong&gt;Automatic translation&lt;/strong&gt; can occur when a home device makes an outgoing network connection. This allows the NAT to match the destination address and port to the originating local address and &lt;a href="http://en.wikipedia.org/wiki/TCP_and_UDP_port"&gt;port&lt;/a&gt;, then translate between them as packets are sent and received. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Manual configuration&lt;/strong&gt; can be performed by an administrator where a given home router port can be redirected to a private device address and port. This allows communication from the public Internet to be directed to a private device by using the public IPv4 address of the home router in combination with an administrator defined port. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Automatic configuration &lt;/strong&gt;can be performed by devices or applications behind the home router using &lt;a href="http://en.wikipedia.org/wiki/Universal_Plug_and_Play"&gt;UPnP&lt;/a&gt;. This allows a device or application to map ports on the router automatically so an administrator doesn’t have to. Most home routers support UPnP today. An unfortunate problem with this approach is that UPnP requires a specific port to be chosen at the time of registration, and this can cause collisions if two callers attempt to register the same port. UPnPv2 and &lt;a href="http://en.wikipedia.org/wiki/NAT_Port_Mapping_Protocol"&gt;NAT-PMP&lt;/a&gt; address this shortcoming. &lt;/li&gt; &lt;/ol&gt;  &lt;h4&gt;NAT Traversal &amp;amp; Security Considerations&lt;/h4&gt;  &lt;p&gt;The term &lt;a href="http://en.wikipedia.org/wiki/NAT_traversal"&gt;NAT traversal&lt;/a&gt; refers to the ability for client devices to address and communicate with listening devices behind a NAT. This turns out to be an incredibly useful thing to do for games, &lt;a href="http://en.wikipedia.org/wiki/Peer-to-peer"&gt;peer-to-peer&lt;/a&gt;, and a variety of other applications. &lt;/p&gt;  &lt;p&gt;Because of the security boundary offered by NAT configurations, a key tenant for any traversal technology is to continue to maintain that security boundary for existing applications and services. The technologies discussed in this article adhere to that tenant. For a detailed discussion of this topic, you may refer to this informational on &lt;a href="http://tools.ietf.org/id/draft-ietf-v6ops-tunnel-security-concerns-01.txt"&gt;Security Concerns With IP Tunneling&lt;/a&gt;.&lt;/p&gt;  &lt;h4&gt;Impact to Applications&lt;/h4&gt;  &lt;p&gt;Generally these strategies result in a decent connectivity story, though complicated, and this carries over into application development. &lt;/p&gt;  &lt;p&gt;In NAT situations, devices don’t really have end-to-end addressability by default, and the port begins to play an overdeveloped role in routing to your home devices to compensate for private addresses not being publicly reachable.&lt;/p&gt;  &lt;p&gt;If your application only makes outgoing connections, the NAT solution will generally handle this transparently for you. The complications occur in applications that not only make but also receive connections – again, very common with &lt;a href="http://en.wikipedia.org/wiki/Peer-to-peer"&gt;peer-to-peer&lt;/a&gt; networks and video games.&lt;/p&gt;  &lt;p&gt;If your application listens on a particular port for incoming connections and relies strictly on IPv4, you might ordinarily need to resort to one of the following techniques:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Add port mapping support to your application so it can automatically detect when it is behind a home router and configure the router to direct traffic to the application instance and port &lt;/li&gt;    &lt;li&gt;Instruct your users to do this manually (which requires far more networking knowledge than is desirable) &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;A key point and drawback to keep in mind is that there is a 1:1 mapping between the Internet facing port on the router and the private IP and port pair of your local device. &lt;/p&gt;  &lt;p&gt;If you want to run a web server from behind your NAT, you might allocate port 80 on the NAT and have it direct traffic to port 80 on Computer 1. If you wanted Computer 2 on the same network to also host a website available on the Internet, a different port on the NAT would need to be allocated, such as port 81 since port 80 is already in use and mapped to Computer 1. &lt;/p&gt;  &lt;p&gt;Visitors would then need to use the router’s public IP address combined with a distinct port to reach the appropriate web server. This is not ideal since web visitors may not be accustomed to having to specify a specific, non-default port.&lt;/p&gt;  &lt;p&gt;Contention for well-known ports demonstrates just one of the problems that may be encountered when relying on port mapping instead of an IP address with enough specificity to more fully handle addressing.&lt;/p&gt;  &lt;p&gt;With that in mind, we’ve made many of these complexities transparent for you in the .NET Framework 4.0.&lt;/p&gt;  &lt;p&gt;If you’re using &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.aspx"&gt;TcpListener&lt;/a&gt; or &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.udpclient.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.sockets.udpclient.aspx"&gt;UdpClient&lt;/a&gt;, just pass into the constructor &lt;b&gt;IPAddress.IPv6Any&lt;/b&gt;, then call &lt;b&gt;AllowNatTraversal&lt;/b&gt; with a value of &lt;strong&gt;true&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; color: blue; font-size: 10pt"&gt;var&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt; listener = &lt;span style="color: blue"&gt;new&lt;/span&gt; TcpListener(IPAddress.IPv6Any, 8000);       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt;listener.AllowNatTraversal(&lt;span style="color: blue"&gt;true&lt;/span&gt;);       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt;listener.Start(); &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;You’ll notice we have been discussing &lt;a href="http://en.wikipedia.org/wiki/IPv4"&gt;IPv4&lt;/a&gt;, but the example above mentions &lt;a href="http://en.wikipedia.org/wiki/IPv6" mce_href="http://en.wikipedia.org/wiki/IPv6"&gt;IPv6&lt;/a&gt;. Have no fear, this will work over intermediate IPv4 networks, it just relies on the origin or destination endpoints supporting IPv6 and a couple key technologies which I’ll cover in more detail below. If your application must run on a PC which only has &lt;a href="http://en.wikipedia.org/wiki/IPv4"&gt;IPv4&lt;/a&gt; installed, a condition that is becoming more rare, then unfortunately this new solution won’t help you right now.&lt;/p&gt;  &lt;p&gt;Another point worth mentioning is that applications which wish to listen on all IP addresses today have to set up two listeners, one for IPv4 using &lt;strong&gt;IPAddress.Any &lt;/strong&gt;and one using &lt;strong&gt;IPAddress.IPv6Any&lt;/strong&gt;. We’re investigating ways to take advantage of “dual mode” sockets so you won’t need to worry about tying your application to a specific IP version in the future.&lt;/p&gt;  &lt;h4&gt;IPv6 Restores Addressability&lt;/h4&gt;  &lt;p mce_keep="true"&gt;What if all your network devices had a public IP address which could be used by other devices to directly communicate with them? This would eliminate the need to use NAT for addressing and once again achieve end-to-end connectivity. With &lt;a href="http://en.wikipedia.org/wiki/IPv6" mce_href="http://en.wikipedia.org/wiki/IPv6"&gt;IPv6&lt;/a&gt;, this is possible.&lt;/p&gt;  &lt;p&gt;IPv6 has a significantly larger address space (2&lt;sup&gt;128&lt;/sup&gt; or about 3.4×10&lt;sup&gt;38&lt;/sup&gt;), and with an address space this size, it is once again possible for every device connected to the Internet to be given a unique address.&lt;/p&gt;  &lt;p&gt;But, there’s a problem. Much of the world is still using IPv4, so exactly how can your application take advantage of IPv6 addresses today?&lt;/p&gt;  &lt;p&gt;Fortunately, a number of transparent solutions have been devised and implemented on platforms and devices so that your application doesn’t need to worry with the specifics so long as it listens on all available IP addresses.&lt;/p&gt;  &lt;h4&gt;6to4 Tunneling&lt;/h4&gt;  &lt;p&gt;Although applications generally don’t need to worry about the underlying mechanism used to allocate an IPv6 address, for context, one such solution is &lt;a href="http://en.wikipedia.org/wiki/6to4" mce_href="http://en.wikipedia.org/wiki/6to4"&gt;6to4&lt;/a&gt; tunneling. &lt;/p&gt;  &lt;p&gt;This solution works great for devices that already have a public IPv4 address. A special range of IPv6 maps to the IPv4 address space, and so with a 6to4 tunnel gateway deployed at the edge, IPv6 connectivity can be automatically enabled.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://technet.microsoft.com/en-us/cc512740.aspx" mce_href="http://technet.microsoft.com/en-us/cc512740.aspx"&gt;Windows supports 6to4&lt;/a&gt;, so if your computer already has a public IPv4 address, or you take your laptop to a hotspot that assigns it one, it probably also has a public IPv6 address through the 6to4 pseudo adapter.&lt;/p&gt;  &lt;p&gt;Of course, in the NAT scenario we’ve been discussing, only the home router has a public IPv4 address. So, to take advantage of 6to4, your router would need to be IPv6 compatible, it would need to be able to assign IPv6 addresses to the local network, and and it would need to have 6to4 tunneling built into it. &lt;/p&gt;  &lt;p&gt;Presently, most home routers don’t support this, though it is something a Windows Server can be configured to do as can standard Windows versions supporting &lt;a href="http://en.wikipedia.org/wiki/Internet_Connection_Sharing" mce_href="http://en.wikipedia.org/wiki/Internet_Connection_Sharing"&gt;Internet Connection Sharing (ICS)&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;So if a home router holds the one and only public IPv4 address, and 6to4 isn’t an option, how can computers behind the NAT use IPv6?&lt;/p&gt;  &lt;h4&gt;Teredo Tunneling&lt;/h4&gt;  &lt;p&gt;Like 6to4, &lt;a href="http://en.wikipedia.org/wiki/Teredo_tunneling" mce_href="http://en.wikipedia.org/wiki/Teredo_tunneling"&gt;Teredo&lt;/a&gt; is another IPv6 transition technology which brings IPv6 connectivity to IPv4 networks. It is described by &lt;a href="http://www.rfc-editor.org/rfc/rfc4380.txt" mce_href="http://www.rfc-editor.org/rfc/rfc4380.txt"&gt;RFC 4380&lt;/a&gt;, is further extended by &lt;a href="http://msdn.microsoft.com/en-us/library/cc247482(PROT.13).aspx"&gt;MS-TERE&lt;/a&gt;, and has even been implemented by the open source community as &lt;a href="http://www.remlab.net/miredo/" mce_href="http://www.remlab.net/miredo/"&gt;Miredo&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;There are a number of technical articles on exactly how Teredo encapsulates IPv6 over IPv4/UDP, which most NATs can forward, so if you’re interested in those details you can find out more from the links at the end of the article.&lt;/p&gt;  &lt;p&gt;What’s important to know here is that Windows OS versions starting with Windows XP SP2 and Windows Server 2003 provide a virtual Teredo adapter which can give you a public IPv6 address in the range 2001:0::/32. This address can be used to listen for incoming connections from the Internet and can be provided to IPv6 enabled clients that wish to connect to your listening service.&lt;/p&gt;  &lt;p&gt;Teredo and related transition technologies free your application from worrying about how to address a computer behind a home router or NAT since typically all you need to do is connect to it using its IPv6 addresses.&lt;/p&gt;  &lt;h4&gt;New for .NET 4.0&lt;/h4&gt;  &lt;p&gt;We’re making some additions in the .NET Framework 4.0 starting with Beta 2 to make these great technologies easier for you to use. The .NET Framework client APIs already support address-based NAT traversal, so the main updates are for listeners.&lt;/p&gt;  &lt;h5&gt;Listeners&lt;/h5&gt;  &lt;p&gt;The &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.aspx"&gt;TcpListener&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.udpclient.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.sockets.udpclient.aspx"&gt;UdpClient&lt;/a&gt; changes were previously mentioned. Use these new methods to toggle whether your application explicitly wants to allow or restrict NAT traversal support.&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;public class&lt;/font&gt; &lt;font color="#008080"&gt;TcpListener&lt;/font&gt;         &lt;br /&gt;{&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;&amp;#160; public void &lt;/font&gt;AllowNatTraversal(&lt;font color="#0000ff"&gt;bool&lt;/font&gt;);         &lt;br /&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;public class&lt;/font&gt; &lt;font color="#008080"&gt;UdpClient&lt;/font&gt;         &lt;br /&gt;{&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;&amp;#160; public void &lt;/font&gt;AllowNatTraversal(&lt;font color="#0000ff"&gt;bool&lt;/font&gt;);         &lt;br /&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;h5&gt;Sockets&lt;/h5&gt;  &lt;p&gt;If you’re using sockets directly, the interface is a little closer to what Winsock exposes via the &lt;a href="http://msdn.microsoft.com/en-us/library/aa832668%28VS.85%29.aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa832668(VS.85).aspx"&gt;IPV6_PROTECTION_LEVEL&lt;/a&gt; socket option. We have exposed this on the &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.aspx"&gt;Socket&lt;/a&gt; class as a new method called &lt;b&gt;SetIPProtectionLevel&lt;/b&gt;.&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; color: blue; font-size: 10pt"&gt;public&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;Socket        &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt;{      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;&amp;#160; public &lt;span style="color: blue"&gt;void&lt;/span&gt;&lt;/span&gt; SetIPProtectionLevel       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; (&lt;font color="#2b91af"&gt;IPProtectionLevel&lt;/font&gt;);       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt;} &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; color: blue; font-size: 10pt"&gt;public&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt; &lt;span style="color: blue"&gt;enum&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;IPProtectionLevel        &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt;{&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Unspecified = –1,&amp;#160;&amp;#160;&amp;#160; &lt;font color="#008000"&gt;// platform default&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;Unrestricted = 10,&amp;#160;&amp;#160; &lt;font color="#008000"&gt;// global with NAT traversal&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt;EdgeRestricted = 20, &lt;font color="#008000"&gt;// global without NAT traversal&lt;/font&gt;       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;Restricted = 30,&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font color="#008000"&gt;// site local&lt;/font&gt;       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt;} &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;Set the &lt;b&gt;IPProtectionLevel&lt;/b&gt; to &lt;b&gt;Unrestricted &lt;/b&gt;prior to &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.bind.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.bind.aspx"&gt;Bind&lt;/a&gt; to allow clients to connect to your listener deployed behind a NAT. This is what the System.Net listener implementations do when you invoke the previously mentioned &lt;b&gt;AllowNatTraversal &lt;/b&gt;method.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;EdgeRestricted &lt;/strong&gt;allows clients to only connect to your listener on IP addresses that aren’t used for NAT traversal (like Teredo). &lt;/p&gt;  &lt;p&gt;&lt;b&gt;Restricted &lt;/b&gt;only allows intranet connectivity (site and local link).&lt;/p&gt;  &lt;p&gt;The actual default setting is &lt;strong&gt;Unspecified&lt;/strong&gt; and left to the underlying platform to determine.&lt;/p&gt;  &lt;p&gt;Starting with Windows Vista, this is equivalent to &lt;strong&gt;Unrestricted &lt;/strong&gt;when the Windows Firewall is enabled and an appropriate rule is configured per the instructions below and &lt;strong&gt;EdgeRestricted &lt;/strong&gt;when it is disabled.&lt;/p&gt;  &lt;p mce_keep="true"&gt;This honors that security point mentioned at the beginning of the article. Many IPv4 networks rely on NAT as a limited form of protection. The default setting protects applications from unintentionally exposing themselves to the Internet in NAT scenarios. Instead, applications must explicitly opt-in to NAT traversal using this socket option or by configuring a Windows Firewall rule.&lt;/p&gt;  &lt;h5&gt;Configuration&lt;/h5&gt;  &lt;p&gt;To enable you to easily turn these features on for your existing applications, you can also control this through &lt;strong&gt;app.config&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: blue; font-size: 9.5pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: #a31515; font-size: 9.5pt"&gt;system.net&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: blue; font-size: 9.5pt"&gt;&amp;gt;        &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: blue; font-size: 9.5pt"&gt;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: #a31515; font-size: 9.5pt"&gt;settings&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: blue; font-size: 9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: #00b050; font-size: 9.5pt"&gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;!-- default is platform defined (Unspecified) –&amp;gt;       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: blue; font-size: 9.5pt"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: #a31515; font-size: 9.5pt"&gt;socket&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: blue; font-size: 9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: red; font-size: 9.5pt"&gt;ipProtectionLevel&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: blue; font-size: 9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: black; font-size: 9.5pt"&gt;&amp;quot;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: blue; font-size: 9.5pt"&gt;Unrestricted |&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: blue; font-size: 9.5pt"&gt;EdgeRestricted | Restricted | Unspecified&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: black; font-size: 9.5pt"&gt;&amp;quot;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: blue; font-size: 9.5pt"&gt;/&amp;gt;      &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: blue; font-size: 9.5pt"&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: blue; font-size: 9.5pt"&gt;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: #a31515; font-size: 9.5pt"&gt;settings&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: blue; font-size: 9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;         &lt;br /&gt;&amp;lt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: blue; font-size: 9.5pt"&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: #a31515; font-size: 9.5pt"&gt;system.net&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: blue; font-size: 9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; background: white; color: blue; font-size: 9.5pt"&gt;      &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;This setting will affect all listening sockets in an &lt;strong&gt;AppDomain&lt;/strong&gt;.&lt;/p&gt;  &lt;h5&gt;Address Discovery&lt;/h5&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;font face="Courier New"&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;It’s not recommended to implement behavior that relies on direct knowledge of IP addresses since this would typically be handled through name resolution, but in some cases, like building peer to peer applications or your own discovery service, it can be useful. &lt;/p&gt;  &lt;p&gt;To get the list of addresses on a host, you could do it the traditional way using &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.networkinformation.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.networkinformation.aspx"&gt;System.Net.NetworkInformation&lt;/a&gt; to enumerate &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkinterface.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkinterface.aspx"&gt;NetworkInterfaces&lt;/a&gt; and their addresses, but we’re adding some new methods which make this simpler and also “wake up” Teredo if it hasn’t been used recently. &lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;public class&lt;/font&gt; &lt;font color="#008080"&gt;IPGlobalProperties&lt;/font&gt;         &lt;br /&gt;{ &lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="Courier New"&gt;       &lt;br /&gt;&amp;#160; &lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#008080"&gt;UnicastIPAddressInformationCollection&lt;/font&gt;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; GetUnicastAddresses();         &lt;br /&gt;        &lt;br /&gt;&amp;#160; &lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#008080"&gt;IAsyncResult&lt;/font&gt; BeginGetUnicastAddresses         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; (&lt;font color="#008080"&gt;AsyncCallback&lt;/font&gt;, &lt;font color="#0000ff"&gt;object&lt;/font&gt;);         &lt;br /&gt;        &lt;br /&gt;&amp;#160; &lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#008080"&gt;UnicastIPAddressInformationCollection&lt;/font&gt;         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; EndGetUnicastAddresses(&lt;font color="#008080"&gt;IAsyncResult&lt;/font&gt;);         &lt;br /&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;This allows you to enumerate addresses as follows.&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; color: blue; font-size: 10pt"&gt;var&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt; addressInfoCollection =      &lt;br /&gt;&amp;#160; IPGlobalProperties.GetIPGlobalProperties()       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; .GetUnicastAddresses(); &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Courier New"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Courier New"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Courier New"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; color: blue; font-size: 10pt"&gt;foreach&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt;(&lt;span style="color: blue"&gt;var&lt;/span&gt; addressInfo &lt;span style="color: blue"&gt;in&lt;/span&gt; addressInfoCollection)       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt;{&amp;#160; &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt;&lt;span&gt;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: rgb(43,145,175)"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: rgb(163,21,21)"&gt;&amp;quot;Address: {0}&amp;quot;&lt;/span&gt;,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; addressInfo.Address);       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt;&lt;font size="1"&gt;&lt;font size="2"&gt;}&lt;/font&gt; &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;Once you have acquired this list of addresses, you can give the address list to your clients out of band and they can use &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.connect%28VS.71%29.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.connect(VS.71).aspx"&gt;Socket.Connect&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.tcpclient.connect.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.sockets.tcpclient.connect.aspx"&gt;TcpClient.Connect&lt;/a&gt;, or even &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.webrequest.create.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.webrequest.create.aspx"&gt;WebRequest.Create&lt;/a&gt; to establish a connection to your service. &lt;/p&gt;  &lt;p&gt;For a savvy way to publish your addresses so others can discover them, check out our &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.peertopeer.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.peertopeer.aspx"&gt;Peer Name Resolution Protocol (PNRP)&lt;/a&gt;. Another great discovery mechanism is the &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.peertopeer.collaboration.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.peertopeer.collaboration.aspx"&gt;Collaboration API&lt;/a&gt;. The traditional mechanism is of course to use &lt;a href="http://en.wikipedia.org/wiki/Domain_Name_System"&gt;DNS&lt;/a&gt; and the System.Net APIs which accept a host name.&lt;/p&gt;  &lt;p&gt;Finally, we’re also adding a convenient property to the &lt;b&gt;IPAddress&lt;/b&gt; class so you can tell if an address you’re dealing with is an IPv6 Teredo address.&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;public class&lt;/font&gt; &lt;font color="#008080"&gt;IPAddress&lt;/font&gt;         &lt;br /&gt;{&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;&amp;#160; public bool&lt;/font&gt; IsIPv6Teredo { &lt;font color="#0000ff"&gt;get&lt;/font&gt;; }         &lt;br /&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;This property is primarily intended to be used for debugging and test scenarios since you will typically want to listen on all available IP addresses so your application can automatically take advantage of new platform enhancements.&lt;/p&gt;  &lt;p&gt;Right now, client support works transparently the whole way up the transport stack, and for listeners we support these new features with &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.aspx"&gt;Sockets&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.aspx"&gt;TcpListener&lt;/a&gt;, and &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.udpclient.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.sockets.udpclient.aspx"&gt;UdpClient&lt;/a&gt;. We hope to extend this to &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx"&gt;HttpListener&lt;/a&gt; in the future.&lt;/p&gt;  &lt;h4&gt;Windows Communication Foundation&lt;/h4&gt;  &lt;p&gt;WCF supports Teredo today for TCP channels when using the &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.activation.configuration.nettcpsection.teredoenabled.aspx"&gt;NetTcpSection.TeredoEnabled&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.configuration.tcptransportelement.teredoenabled.aspx"&gt;TcpTransportElement.TeredoEnabled&lt;/a&gt; properties.&lt;/p&gt;  &lt;h4&gt;Firewall Considerations&lt;/h4&gt;  &lt;p&gt;By default, the Windows Firewall blocks incoming connections. For your listener to be accessible, you will want to create a firewall rule. This is true of any listening application, not just ones that wish to take advantage of NAT traversal. You can do this programmatically, and since adding firewall rules requires &lt;a href="http://en.wikipedia.org/wiki/User_Account_Control" mce_href="http://en.wikipedia.org/wiki/User_Account_Control"&gt;UAC elevation&lt;/a&gt;, application installation is the best time to do this. Even though the rule can be added at install time, it can be configured to activate only while the application is running.&lt;/p&gt;  &lt;p&gt;The firewall can be controlled using COM interop. Add a project reference to &lt;b&gt;FirewallApi.dll&lt;/b&gt;. You can then add a rule with the following code.&lt;/p&gt;  &lt;div style="border-bottom: rgb(165,165,165) 1pt solid; border-left: rgb(165,165,165) 1pt solid; padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: rgb(242,242,242); border-top: rgb(165,165,165) 1pt solid; border-right: rgb(165,165,165) 1pt solid; padding-top: 1pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial"&gt;   &lt;p class="Code"&gt;&lt;font size="2"&gt;&lt;font face="Courier New"&gt;&lt;span style="color: rgb(43,145,175)"&gt;Guid&lt;/span&gt; netFwRuleUuid = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;Guid&lt;/span&gt;(&lt;span style="color: rgb(163,21,21)"&gt;&amp;quot;{2C5BC43E-3369-4C33-AB0C-BE9469677AF4}&amp;quot;&lt;/span&gt;);           &lt;br /&gt;&lt;span style="color: rgb(43,145,175)"&gt;INetFwRule&lt;/span&gt; rule = (&lt;span style="color: rgb(43,145,175)"&gt;INetFwRule&lt;/span&gt;)&lt;span style="color: rgb(43,145,175)"&gt;Activator&lt;/span&gt;.CreateInstance(&lt;span style="color: rgb(43,145,175)"&gt;Type&lt;/span&gt;.GetTypeFromCLSID(netFwRuleUuid)); &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;    &lt;p class="Code"&gt;&lt;font size="2" face="Courier New"&gt;rule.Action = &lt;span style="color: rgb(43,145,175)"&gt;NET_FW_ACTION_&lt;/span&gt;.NET_FW_ACTION_ALLOW;         &lt;br /&gt;rule.ApplicationName = @&lt;span style="color: rgb(163,21,21)"&gt;&amp;quot;C:\Program Files\My Application\MyApplication.exe&amp;quot;&lt;/span&gt;;         &lt;br /&gt;rule.Description = &lt;span style="color: rgb(163,21,21)"&gt;&amp;quot;My Rule Description&amp;quot;&lt;/span&gt;;         &lt;br /&gt;rule.Direction = &lt;span style="color: rgb(43,145,175)"&gt;NET_FW_RULE_DIRECTION_&lt;/span&gt;.NET_FW_RULE_DIR_IN;         &lt;br /&gt;rule.EdgeTraversal = &lt;span style="color: blue"&gt;true&lt;/span&gt;;         &lt;br /&gt;rule.Enabled = &lt;span style="color: blue"&gt;true&lt;/span&gt;;         &lt;br /&gt;rule.Grouping = &lt;span style="color: rgb(163,21,21)"&gt;&amp;quot;My Rule Group&amp;quot;&lt;/span&gt;;         &lt;br /&gt;rule.Name = &lt;span style="color: rgb(163,21,21)"&gt;&amp;quot;My Rule Name&amp;quot;&lt;/span&gt;;         &lt;br /&gt;rule.Protocol = (&lt;span style="color: blue"&gt;int&lt;/span&gt;)&lt;span style="color: rgb(43,145,175)"&gt;ProtocolType&lt;/span&gt;.Tcp; &lt;/font&gt;&lt;/p&gt;    &lt;p class="Code"&gt;&lt;font size="2" face="Courier New"&gt;Guid netFwPolicy2Uuid = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;Guid&lt;/span&gt;(&lt;span style="color: rgb(163,21,21)"&gt;&amp;quot;{E2B3C97F-6AE1-41AC-817A-F6F92166D7DD}&amp;quot;&lt;/span&gt;);         &lt;br /&gt;&lt;span style="color: rgb(43,145,175)"&gt;INetFwPolicy2&lt;/span&gt; policy = (&lt;span style="color: rgb(43,145,175)"&gt;INetFwPolicy2&lt;/span&gt;)&lt;span style="color: rgb(43,145,175)"&gt;Activator&lt;/span&gt;.CreateInstance(&lt;span style="color: rgb(43,145,175)"&gt;Type&lt;/span&gt;.GetTypeFromCLSID(netFwPolicy2Uuid));         &lt;br /&gt;policy.Rules.Add(rule);&lt;/font&gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;Note that to enable NAT traversal, the &lt;strong&gt;EdgeTraversal&lt;/strong&gt; flag must be set to &lt;strong&gt;true&lt;/strong&gt; since a firewall rule with a setting of &lt;strong&gt;false&lt;/strong&gt; (the default) is used to prevent NAT traversal even when an application sets the &lt;strong&gt;IPProtectionLevel&lt;/strong&gt; for its sockets to &lt;strong&gt;Unrestricted&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;Starting with Windows 7, although you can still use the approach above, there is more control over the default NAT traversal behavior using the &lt;a href="http://msdn.microsoft.com/en-us/library/dd607256(VS.85).aspx"&gt;InetFwRule2&lt;/a&gt; interface and &lt;a href="http://msdn.microsoft.com/en-us/library/dd607258(VS.85).aspx"&gt;NET_FW_EDGE_TRAVERSAL_TYPE&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Third party firewalls may require custom configuration or may prompt the user for permission on first application launch.&lt;/p&gt;  &lt;h4&gt;Parting Thoughts&lt;/h4&gt;  &lt;p&gt;With IPv6 and its related transition technologies becoming ubiquitous, now is a great time to take advantage of these capabilities in your applications, and the .NET Framework 4.0 makes it easy to get started.&lt;/p&gt;  &lt;h4&gt;Additional References&lt;/h4&gt;  &lt;p&gt;&lt;a href="http://technet.microsoft.com/en-us/network/bb530961.aspx" mce_href="http://technet.microsoft.com/en-us/network/bb530961.aspx"&gt;Microsoft IPv6 Website&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/bb726951.aspx" mce_href="http://technet.microsoft.com/en-us/library/bb726951.aspx"&gt;IPv6 Transition Technologies&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/bb457011.aspx" mce_href="http://technet.microsoft.com/en-us/library/bb457011.aspx"&gt;TechNet Teredo Overview&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/bb457042.aspx" mce_href="http://technet.microsoft.com/en-us/library/bb457042.aspx"&gt;TechNet Using IPv6 and Teredo&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/aa965909%28VS.85%29.aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa965909(VS.85).aspx"&gt;MSDN Teredo Site&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://support.microsoft.com/kb/968510" mce_href="http://support.microsoft.com/kb/968510"&gt;Firewall requirements for coexisting with Teredo&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tools.ietf.org/id/draft-ietf-v6ops-tunnel-security-concerns-01.txt"&gt;Security Concerns With IP Tunneling&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Special thanks to &lt;a href="http://research.microsoft.com/en-us/um/people/dthaler/"&gt;Dave Thaler&lt;/a&gt; for his insights and expert feedback.&lt;/p&gt;  &lt;p&gt;~ Aaron Oneal | NCL Program Manager&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9598006" width="1" height="1"&gt;</content><author><name>Aaron Oneal</name><uri>http://blogs.msdn.com/Aaron-Oneal-_5B00_MSFT_5D00_/ProfileUrlRedirect.ashx</uri></author><category term="Teredo" scheme="http://blogs.msdn.com/b/ncl/archive/tags/Teredo/" /><category term="IPv6" scheme="http://blogs.msdn.com/b/ncl/archive/tags/IPv6/" /><category term="NAT Traversal" scheme="http://blogs.msdn.com/b/ncl/archive/tags/NAT+Traversal/" /><category term="Sockets" scheme="http://blogs.msdn.com/b/ncl/archive/tags/Sockets/" /><category term=".NET Framework 4.0" scheme="http://blogs.msdn.com/b/ncl/archive/tags/-NET+Framework+4-0/" /></entry><entry><title>New NCL Features in .NET 4.0 Beta 2</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/ncl/archive/2009/07/20/new-ncl-features-in-net-4-0-beta-2.aspx" /><id>http://blogs.msdn.com/b/ncl/archive/2009/07/20/new-ncl-features-in-net-4-0-beta-2.aspx</id><published>2009-07-20T18:59:00Z</published><updated>2009-07-20T18:59:00Z</updated><content type="html">&lt;p&gt;We’re introducing some new features starting with .NET 4.0 Beta 2 that you may find useful. Additional information will be available on MSDN and in subsequent articles. If you have any questions or comments, let us know!&lt;/p&gt;  &lt;h3&gt;Sockets &lt;/h3&gt;  &lt;h4&gt;DnsEndPoint&lt;/h4&gt;  &lt;p&gt;This feature was first introduced in Silverlight 2 and it allows you to connect to a listening socket by DNS name, simplifying the connect experience. Now you can take advantage of this in .NET as well.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Before&lt;/strong&gt;&lt;/p&gt;  &lt;table border="1" cellspacing="0" cellpadding="2" width="525"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="523"&gt;         &lt;p style="text-indent: -13.7pt; margin: 3.85pt 0in 0pt 13.7pt; vertical-align: baseline; mso-line-break-override: restrictions; punctuation-wrap: simple"&gt;&lt;span style="font-family: consolas; color: black; font-size: 10pt; mso-fareast-font-family: +mn-ea"&gt;IPAddress[] IPs = Dns.GetHostAddresses(&lt;/span&gt;&lt;span style="font-family: consolas; color: maroon; font-size: 10pt; mso-fareast-font-family: +mn-ea"&gt;&amp;quot;www.contoso.com&amp;quot;&lt;/span&gt;&lt;span style="font-family: consolas; color: black; font-size: 10pt; mso-fareast-font-family: +mn-ea"&gt;); &lt;/span&gt;&lt;span style="font-size: 10pt"&gt;&lt;/span&gt;&lt;/p&gt;          &lt;p&gt;&lt;font face="Consolas"&gt;&lt;/font&gt;&lt;/p&gt;          &lt;p&gt;&lt;/p&gt;          &lt;p&gt;&lt;font size="2" face="Consolas"&gt;&lt;/font&gt;&lt;/p&gt;          &lt;p style="text-indent: -13.7pt; margin: 3.85pt 0in 0pt 13.7pt; vertical-align: baseline; mso-line-break-override: restrictions; punctuation-wrap: simple"&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-fareast-font-family: +mn-ea"&gt;foreach&lt;/span&gt;&lt;span style="font-family: consolas; color: black; font-size: 10pt; mso-fareast-font-family: +mn-ea"&gt;(IPAddress ip in IPs) {              &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: black; font-size: 10pt; mso-fareast-font-family: +mn-ea"&gt;try {              &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: black; font-size: 10pt; mso-fareast-font-family: +mn-ea"&gt;&amp;#160; socket.Connect(&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-fareast-font-family: +mn-ea"&gt;new&lt;/span&gt;&lt;span style="font-family: consolas; color: black; font-size: 10pt; mso-fareast-font-family: +mn-ea"&gt; IPEndPoint(ip, port));              &lt;br /&gt;&amp;#160; &lt;/span&gt;&lt;span style="font-family: consolas; color: black; font-size: 10pt; mso-fareast-font-family: +mn-ea"&gt;break;&lt;/span&gt;&lt;span style="font-size: 10pt"&gt;&lt;font face="Consolas"&gt;&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: black; font-size: 10pt; mso-fareast-font-family: +mn-ea"&gt;}              &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: black; font-size: 10pt; mso-fareast-font-family: +mn-ea"&gt;catch(SocketException) { continue; }&lt;/span&gt;&lt;span style="font-size: 10pt"&gt;&lt;font face="Consolas"&gt; &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;          &lt;p style="text-indent: -13.7pt; margin: 3.85pt 0in 0pt 13.7pt; vertical-align: baseline; mso-line-break-override: restrictions; punctuation-wrap: simple"&gt;&lt;span style="font-family: consolas; color: black; font-size: 10pt; mso-fareast-font-family: +mn-ea"&gt;}&lt;/span&gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;strong&gt;After&lt;/strong&gt;&lt;/p&gt;  &lt;table border="1" cellspacing="0" cellpadding="2" width="525"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="523"&gt;         &lt;p&gt;&lt;span style="font-family: consolas; color: black; font-size: 10pt; mso-fareast-font-family: +mn-ea"&gt;socket.Connect(&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 10pt; mso-fareast-font-family: +mn-ea"&gt;new&lt;/span&gt;&lt;span style="font-family: consolas; color: black; font-size: 10pt; mso-fareast-font-family: +mn-ea"&gt; DnsEndPoint(&lt;/span&gt;&lt;span style="font-family: consolas; color: maroon; font-size: 10pt; mso-fareast-font-family: +mn-ea"&gt;&amp;quot;www.contoso.com&amp;quot;&lt;/span&gt;&lt;span style="font-family: consolas; color: black; font-size: 10pt; mso-fareast-font-family: +mn-ea"&gt;, port));&lt;/span&gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;h4&gt;IP Version Neutrality&lt;/h4&gt;  &lt;p&gt;Starting with Windows Vista, the TCP/IP stack has features which allow you to write sockets applications that can transparently handle multiple versions of the Internet Protocol. This works by creating an IPv6 socket and setting the &lt;strong&gt;IPv6Only&lt;/strong&gt; socket option to false. Once set, the IPv6 socket is also able to accept IPv4 traffic. This frees your application from the traditional model of having to create multiple sockets for each IP version.&lt;/p&gt;  &lt;table border="1" cellspacing="0" cellpadding="2" width="525"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="523"&gt;         &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt; mso-no-proof: yes"&gt;&lt;font face="Consolas"&gt;Socket socket = &lt;span style="color: blue"&gt;new&lt;/span&gt; Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp); &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;          &lt;p&gt;&lt;font face="Consolas"&gt;&lt;/font&gt;&lt;/p&gt;          &lt;p&gt;&lt;/p&gt;          &lt;p&gt;&lt;font size="2" face="Consolas"&gt;&lt;/font&gt;&lt;/p&gt;          &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt; mso-no-proof: yes"&gt;&lt;font face="Consolas"&gt;socket.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, 0); &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;          &lt;p&gt;&lt;font face="Consolas"&gt;&lt;/font&gt;&lt;/p&gt;          &lt;p&gt;&lt;/p&gt;          &lt;p&gt;&lt;font size="2" face="Consolas"&gt;&lt;/font&gt;&lt;/p&gt;          &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt; mso-no-proof: yes"&gt;&lt;font face="Consolas"&gt;socket.Bind(&lt;span style="color: blue"&gt;new&lt;/span&gt; IPEndPoint(IPAddress.IPv6Any, 8000));                 &lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt; mso-no-proof: yes"&gt;socket.Listen(5);                &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt; mso-no-proof: yes"&gt;Socket client = sock.Accept();&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;/p&gt;  &lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h3&gt;SSL Encryption Policy&lt;/h3&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;/p&gt;  &lt;p&gt;Traditionally SSL is used both for encryption and for authentication / message integrity. In some cases, however, encryption is not required or desired. This could be for interoperability with other systems or performance reasons. Therefore, you can now change the default encryption policy for SSL. In some circles, this is also referred to as using a “null cipher”.&lt;/p&gt;  &lt;table border="1" cellspacing="0" cellpadding="2" width="525"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="525"&gt;         &lt;p&gt;&lt;font size="2"&gt;&lt;font face="consolas"&gt;&lt;font color="#0000ff"&gt;namespace&lt;/font&gt; System.Net.Security                 &lt;br /&gt;{&amp;#160; &lt;br /&gt;&amp;#160; &lt;font color="#0000ff"&gt;public enum&lt;/font&gt; EncryptionPolicy&amp;#160; &lt;br /&gt;&amp;#160; {&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; RequireEncryption, &lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="consolas"&gt;&lt;font color="#008000"&gt;// always require encryption&amp;#160; &lt;br /&gt;&lt;/font&gt;&amp;#160;&amp;#160;&amp;#160; AllowNoEncryption, &lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="consolas"&gt;&lt;font color="#008000"&gt;// prefer full encryption; allow none if server agrees                  &lt;br /&gt;&lt;/font&gt;&amp;#160;&amp;#160;&amp;#160; NoEncryption&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font face="consolas"&gt;&lt;font color="#008000"&gt;// require no encryption; fail if server requires it                  &lt;br /&gt;&lt;/font&gt;&amp;#160; }                 &lt;br /&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="line-height: 115%; font-size: 10pt"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;This setting can be configured in the following places.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;SslStream &lt;/li&gt;    &lt;li&gt;ServicePointManager for HttpWebRequest, FtpWebRequest, SmtpClient &lt;/li&gt;    &lt;li&gt;Machine.config or app.config &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;/p&gt;  &lt;h3&gt;SmtpClient &lt;/h3&gt;  &lt;h4&gt;SSL Configuration&lt;/h4&gt;  &lt;p&gt;It is now possible to enable explicit SSL in SmtpClient via application config in addition to the runtime option that was already available.&lt;/p&gt;  &lt;p style="mso-layout-grid-align: none" class="MsoNormal"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: #a31515; font-size: 10pt; mso-no-proof: yes"&gt;configuration&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&amp;gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: #a31515; font-size: 10pt; mso-no-proof: yes"&gt;system.net&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&amp;gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: #a31515; font-size: 10pt; mso-no-proof: yes"&gt;mailSettings&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&amp;gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: #a31515; font-size: 10pt; mso-no-proof: yes"&gt;smtp&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt; &lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: red; font-size: 10pt; mso-no-proof: yes"&gt;deliveryMethod&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes"&gt;&amp;quot;&lt;span style="color: blue"&gt;network&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;        &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: #a31515; font-size: 10pt; mso-no-proof: yes"&gt;network      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: red; font-size: 10pt; mso-no-proof: yes"&gt;host&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes"&gt;&amp;quot;&lt;span style="color: blue"&gt;localhost&lt;/span&gt;&amp;quot;       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: red; font-size: 10pt; mso-no-proof: yes"&gt;port&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes"&gt;&amp;quot;&lt;span style="color: blue"&gt;25&lt;/span&gt;&amp;quot;       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: red; font-size: 10pt; mso-no-proof: yes"&gt;defaultCredentials&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes"&gt;&amp;quot;&lt;span style="color: blue"&gt;true&lt;/span&gt;&amp;quot;       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: red; font-size: 10pt; mso-no-proof: yes"&gt;enableSsl&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;/strong&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes"&gt;&lt;strong&gt;&amp;quot;&lt;span style="color: blue"&gt;true&lt;/span&gt;&amp;quot;         &lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;/&amp;gt;       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: #a31515; font-size: 10pt; mso-no-proof: yes"&gt;smtp&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&amp;gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: #a31515; font-size: 10pt; mso-no-proof: yes"&gt;mailSettings&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&amp;gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: #a31515; font-size: 10pt; mso-no-proof: yes"&gt;system.net&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&amp;gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: #a31515; font-size: 10pt; mso-no-proof: yes"&gt;configuration&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;h4&gt;Header Encoding&lt;/h4&gt;  &lt;p&gt;Prior versions of .NET restricted headers to ASCII encoding. A new &lt;strong&gt;MailMessage.HeadersEncoding&lt;/strong&gt; property will allow for an alternate encoding to be specified for the headers added to the &lt;strong&gt;MailMessage.Headers&lt;/strong&gt; collection.&lt;/p&gt;  &lt;h4&gt;Multiple ReplyTo Addresses&lt;/h4&gt;  &lt;p&gt;The &lt;strong&gt;MailMessage.ReplyTo&lt;/strong&gt; property only allows a single address to be added. We’re adding a new collection property called &lt;strong&gt;MailMessage.ReplyToList &lt;/strong&gt;to support multiple addresses.&lt;/p&gt;  &lt;h3&gt;HttpWebRequest &lt;/h3&gt;  &lt;h4&gt;64-bit Range Header Support&lt;/h4&gt;  &lt;p&gt;When a client program makes an HTTP request, that request includes a number of headers which determine how the server will respond. One of those headers is the &lt;b&gt;Range&lt;/b&gt; header as described in RFC 2616 (obsoletes 2068). The &lt;b&gt;Range&lt;/b&gt; header on a request allows a client to request that it only wants to receive some part of the specified range of bytes in an HTTP entity. Servers are not required to support Range header requests. &lt;/p&gt;  &lt;p&gt;An example of a range header in the HTTP request is:&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Range: bytes=1024-2047&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Some of the uses of the range header include:&lt;/p&gt;  &lt;p&gt;1. Manually maintaining “QOS” (quality of service) for streaming media. For example, a sophisticated movie viewer program might download the video and audio of a movie separately, downloading the “next” pieces only when needed&lt;/p&gt;  &lt;p&gt;2. Manually handling file caching for interrupted downloads&lt;/p&gt;  &lt;p&gt;The existing framework includes a set of public &lt;b&gt;HttpWebRequest.AddRange&lt;/b&gt; methods as specified on MSDN at &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.addrange.aspx"&gt;http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.addrange.aspx&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Additional overloads supporting &lt;strong&gt;Int64 &lt;/strong&gt;ranges have been added.&lt;/p&gt;  &lt;h4&gt;Date Header Support&lt;/h4&gt;  &lt;p&gt;A new &lt;strong&gt;HttpWebRequest.Date&lt;/strong&gt; property has been added to support setting of the HTTP Date header.&lt;/p&gt;  &lt;h4&gt;Host Header Support&lt;/h4&gt;  &lt;p&gt;A new &lt;strong&gt;HttpWebRequest.Host &lt;/strong&gt;property has been added to allow configuration of the HTTP Host header. This header can be used during testing and with load balancers, for example, to ensure the TCP connection is established to a particular IP address but that the client can still address the intended web site at the specified HTTP server endpoint. For example:&lt;/p&gt;  &lt;table border="1" cellspacing="0" cellpadding="2" width="525"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="525"&gt;         &lt;p&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; color: blue; font-size: 10pt"&gt;var&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt; request = WebRequest.Create(&lt;font face="Consolas"&gt;&lt;span style="font-family: consolas; color: maroon; font-size: 10pt; mso-fareast-font-family: +mn-ea"&gt;&amp;quot;http://127.0.0.1/&amp;quot;&lt;/span&gt;&lt;/font&gt;) as HttpWebRequest;               &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt;request.Host = &lt;span style="font-family: consolas; color: maroon; font-size: 10pt; mso-fareast-font-family: +mn-ea"&gt;&amp;quot;contoso.com&amp;quot;&lt;/span&gt;;               &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; color: blue; font-size: 10pt"&gt;var&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt; response = &lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt;request.GetResponse();&lt;/span&gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;h3&gt;WebRequest Performance Counters&lt;/h3&gt;  &lt;p&gt;Troubleshooting a server application can be difficult, and one key tool for this is the Windows Performance Monitor. With the addition of new performance counters for WebRequest, this is now easier. The diagram below (click for a larger view) shows the new counters and the points in the lifetime of an HttpWebRequest where they are updated.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/ncl/WindowsLiveWriter/NewNCLFeaturesin.NET4.0Beta2_78A0/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/ncl/WindowsLiveWriter/NewNCLFeaturesin.NET4.0Beta2_78A0/image_thumb.png" width="506" height="323" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;NAT Traversal&lt;/h3&gt;  &lt;p&gt;The term &lt;a href="http://en.wikipedia.org/wiki/NAT_traversal"&gt;NAT traversal&lt;/a&gt; refers to the ability for client devices to address and communicate with listening devices behind a NAT. This turns out to be an incredibly useful thing to do for games, &lt;a href="http://en.wikipedia.org/wiki/Peer-to-peer"&gt;peer-to-peer&lt;/a&gt;, and a variety of other applications. A subsequent article will go into full detail about what is available, but here’s a quick preview of one aspect of this feature.&lt;/p&gt;  &lt;p&gt;If you’re using &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.aspx"&gt;TcpListener&lt;/a&gt; or &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.udpclient.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.sockets.udpclient.aspx"&gt;UdpClient&lt;/a&gt;, just pass into the constructor &lt;b&gt;IPAddress.IPv6Any&lt;/b&gt;, then call &lt;b&gt;AllowNatTraversal&lt;/b&gt; with a value of &lt;strong&gt;true &lt;/strong&gt;to support NAT traversal in your application.&lt;/p&gt;  &lt;table border="1" cellspacing="0" cellpadding="2" width="525"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="525"&gt;         &lt;p&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; color: blue; font-size: 10pt"&gt;var&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt; listener = &lt;span style="color: blue"&gt;new&lt;/span&gt; TcpListener(IPAddress.IPv6Any, 8000);               &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt;listener.AllowNatTraversal(&lt;span style="color: blue"&gt;true&lt;/span&gt;);               &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;; font-size: 10pt"&gt;listener.Start(); &lt;/span&gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt; &lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt"&gt;   &lt;p&gt;&lt;/p&gt; &lt;/span&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;h3&gt;Escaped Character Support in Uri&lt;/h3&gt;  &lt;p&gt;With REST becoming a more popular way of creating web services, and with the key role Uri plays in resource identification, we are providing a way to relax some of the canonicalization performed by our current &lt;strong&gt;http(s)&lt;/strong&gt; scheme parser. If you have encountered issues with special characters such as &lt;strong&gt;/ &lt;/strong&gt;or&lt;strong&gt; \ &lt;/strong&gt;being unescaped, you now have the following configuration options at your disposal.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 9pt"&gt;xml&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt; &lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 9pt"&gt;version&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;=&lt;/span&gt;&lt;span style="font-family: consolas; font-size: 9pt"&gt;&amp;quot;&lt;span style="color: blue"&gt;1.0&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;encoding&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;utf-8&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt; ?&amp;gt;        &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 9pt"&gt;configuration&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 9pt"&gt;configSections&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 9pt"&gt;section&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt; &lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 9pt"&gt;name&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;=&lt;/span&gt;&lt;span style="font-family: consolas; font-size: 9pt"&gt;&amp;quot;&lt;span style="color: blue"&gt;uri&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;System.Configuration.UriSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt; /&amp;gt;        &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 9pt"&gt;configSections&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 9pt"&gt;uri&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 9pt"&gt;schemeSettings&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 9pt"&gt;add&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt; &lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 9pt"&gt;name&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;=&lt;/span&gt;&lt;span style="font-family: consolas; font-size: 9pt"&gt;&amp;quot;&lt;span style="color: blue"&gt;http&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;genericUriParserOptions&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;DontUnescapePathDotsAndSlashes&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt; /&amp;gt;        &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 9pt"&gt;add&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt; &lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 9pt"&gt;name&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;=&lt;/span&gt;&lt;span style="font-family: consolas; font-size: 9pt"&gt;&amp;quot;&lt;span style="color: blue"&gt;https&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;genericUriParserOptions&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;DontUnescapePathDotsAndSlashes&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt; /&amp;gt;        &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 9pt"&gt;schemeSettings&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 9pt"&gt;uri&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-family: consolas; font-size: 9pt"&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 9pt"&gt;system.net&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 9pt"&gt;settings&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 9pt"&gt;httpListener&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt; &lt;/span&gt;&lt;span style="font-family: consolas; color: red; font-size: 9pt"&gt;unescapeRequestUrl&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;=&lt;/span&gt;&lt;span style="font-family: consolas; font-size: 9pt"&gt;&amp;quot;&lt;span style="color: blue"&gt;false&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt; /&amp;gt;        &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 9pt"&gt;settings&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 9pt"&gt;system.net&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; font-size: 9pt"&gt;configuration&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; font-size: 9pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;This will allow you to turn off this form of escaping in Uri and also in the RequestUrl received from HttpListener. The latter setting will also impact application hosted WCF services using HTTP bindings since those are built on HttpListener.&lt;/p&gt;  &lt;h3&gt;Bug Fixes&lt;/h3&gt;  &lt;p&gt;No release would be complete without bug fixes, and we’re addressing plenty of those! The NCL team has fixed over 150&lt;strong&gt; &lt;/strong&gt;bugs as of this milestone. Our focus during triage was on:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Stability (fix hangs, crashes and improve long-running/data center scenarios such as fix memory leaks) &lt;/li&gt;    &lt;li&gt;Performance &lt;/li&gt;    &lt;li&gt;RFC compliance with URI, FTP, HTTP, SMTP &lt;/li&gt;    &lt;li&gt;Internationalization (better handling of Unicode characters, etc.) in URI, FTP, HTTP, SMTP &lt;/li&gt;    &lt;li&gt;IPv6 connectivity &lt;/li&gt;    &lt;li&gt;Customer reported bugs through our Connect, MSDN Forums, and other channels &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Please try out the new release when available and let us know what you think!&lt;/p&gt;  &lt;p&gt;~ NCL Team&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9834456" width="1" height="1"&gt;</content><author><name>Aaron Oneal</name><uri>http://blogs.msdn.com/Aaron-Oneal-_5B00_MSFT_5D00_/ProfileUrlRedirect.ashx</uri></author><category term="New Features" scheme="http://blogs.msdn.com/b/ncl/archive/tags/New+Features/" /><category term=".NET Framework 4.0" scheme="http://blogs.msdn.com/b/ncl/archive/tags/-NET+Framework+4-0/" /></entry><entry><title>Why does Silverlight have a restricted port range for Sockets?</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/ncl/archive/2009/06/23/why-does-silverlight-have-a-restricted-port-range-for-sockets.aspx" /><id>http://blogs.msdn.com/b/ncl/archive/2009/06/23/why-does-silverlight-have-a-restricted-port-range-for-sockets.aspx</id><published>2009-06-23T22:52:00Z</published><updated>2009-06-23T22:52:00Z</updated><content type="html">&lt;p&gt;Silverlight restricts the ports of outgoing TCP socket connections to the range 4502 – 4534. Connecting to a different port requires the use of a server-side proxy or port redirector.&lt;/p&gt;  &lt;p&gt;One of the most common questions we hear from customers about this is, “Why do you restrict the port range in Silverlight? It doesn’t add any extra security.”&lt;/p&gt;  &lt;p&gt;Actually, it does. The short explanation is, it gives network administrators control over their infrastructure by providing a convenient way to distinguish and route Silverlight traffic. For the long answer, read on.&lt;/p&gt;  &lt;h5&gt;Desktop trust model&lt;/h5&gt;  &lt;p&gt;When you run an application on your desktop you typically:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Have intentionally downloaded and/or installed the application &lt;/li&gt;    &lt;li&gt;Have intentionally executed the application &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;In the case of a managed corporate environment you:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Have been granted permission by an IT administrator to install and/or execute applications on your PC &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;In short, by being able to install and explicitly execute an application, you are asserting your trust of that application to not go rummaging around your file system or corporate network, for instance.&lt;/p&gt;  &lt;h5&gt;Web trust model&lt;/h5&gt;  &lt;p&gt;The web trust model is different. A web browser is a trusted desktop application, so per above, there are expectations it will not do anything malicious. Since web content can come from anywhere, there are no security guarantees about the intentions of the content provider.&lt;/p&gt;  &lt;p&gt;Moreover, the explicitness of application install and execution is not present by design. That is, just by navigating to a website, a number of Silverlight applications could be started – an advertisement playing in the corner of the page, a hidden application with no UI, etc.&lt;/p&gt;  &lt;p&gt;None of these Silverlight applications should be able to break out of the “sandbox” trust model without your knowledge, and nothing short of application signing, a domain trust model, prompting, etc. could establish that trust. &lt;/p&gt;  &lt;p&gt;We’ve worked hard to keep the experience as unobtrusive as possible by generally avoiding prompting. But even when necessary, such trust models are fragile in nature because there is such a tendency to just click OK when you’re on a trusted site, even if the content came from elsewhere. &lt;/p&gt;  &lt;h5&gt;User vs. IT admin security decision&lt;/h5&gt;  &lt;p&gt;The other consideration is whether the decision to trust a website or Silverlight application rests with the web browser user or with the IT administrator. An insecure client on the network can be an entry point to other normally secured systems.&lt;/p&gt;  &lt;p&gt;Here is one &lt;a href="http://www.cert.org/tech_tips/ftp_port_attacks.html"&gt;well-known FTP attack&lt;/a&gt; for why a trust decision like this is necessary and why it needs to rest with the IT admin.&lt;/p&gt;  &lt;p&gt;The FTP protocol has a PORT command which is typically used to establish connections using “active” FTP. It can also be used to initiate server-to-server transfers.&lt;/p&gt;  &lt;p&gt;In a malicious case, the command can be exploited to perform port scanning, or in the case of some active packet filtering devices, to actually open ports in the firewall. &lt;/p&gt;  &lt;p&gt;With a desktop FTP client application that the user or IT admin has installed, the behavior of that client is trusted to be benign and these commands are issued at the request of the user. The active packet filter is doing what it was configured to do by opening the necessary ports to allow the connection.&lt;/p&gt;  &lt;p&gt;Now imagine if Silverlight were allowed to send those same commands. You visit a website, a hidden application sets up a TCP connection back to its server of origin, and then it sends the PORT command which promptly opens a hole in your firewall. The website then uses this open port to establish a connection back to a victim machine on the internal network. The user never intended this action and therefore the trust model is broken. Moreover, the entire network has been placed at risk since the connection could be to a different computer than the user’s who indicated trust of the application.&lt;/p&gt;  &lt;p&gt;Now, such attacks can typically be mitigated through additional configuration and patching, but this class of attack tends to re-surface with various protocols because of the liberties active filters take. &lt;/p&gt;  &lt;p&gt;Similar exploits exist for HTTP. You’ll notice that Silverlight, Flash, XmlHttpRequest, etc. block a number of request headers. Now imagine if we allowed TCP connections over port 80 and a malicious application could craft their own HTTP request, effectively bypassing our HTTP implementation which has these checks.&lt;/p&gt;  &lt;p&gt;For a detailed look at one such threat, please see &lt;a href="http://www.thesecuritypractice.com/the_security_practice/2009/03/socket-capable-browser-plugins-result-in-transparent-proxy-abuse.html"&gt;this article&lt;/a&gt; about &lt;a href="http://www.kb.cert.org/vuls/id/435052"&gt;CERT’s VU#435052&lt;/a&gt;. Security researcher &lt;a href="http://en.wikipedia.org/wiki/Dan_Kaminsky"&gt;Dan Kaminsky&lt;/a&gt; has published a &lt;a href="http://www.scribd.com/doc/13501365/Staring-Into-The-Abyss"&gt;presentation&lt;/a&gt; and &lt;a href="http://www.doxpara.com/Staring%20Into%20The%20Abyss.pdf"&gt;paper&lt;/a&gt; on the subject.&lt;/p&gt;  &lt;p&gt;In a corporate environment, IT administrators need to be able to secure their networks against such attacks, so there must be a way for them to retain control of these security decisions and to also be able to distinguish Silverlight traffic from trusted application traffic that might be using similar protocols.&lt;/p&gt;  &lt;h5&gt;Port ranges and transparent proxy abuse&lt;/h5&gt;  &lt;p&gt;So how do port ranges help? Well, it’s unlikely your active packet filter scanning FTP port 21 is going to notice if someone attempts to send a maliciously crafted command over port 4502. Moreover, with a clearly identified port range of Silverlight-only traffic, it’s easy to configure such filtering devices to handle that traffic differently and with an appropriate level of trust.&lt;/p&gt;  &lt;h5&gt;Other solutions&lt;/h5&gt;  &lt;p&gt;There are other solutions to this problem. I briefly mentioned some approaches the application model could take along with some of the drawbacks. Another alternative would be to require obfuscation or encryption of all traffic to keep active packet filters from inspecting packets. This has the drawback of not necessarily being compatible with all protocols, with defeating the optimizations active packet filters can provide, and with making it more difficult to distinguish between desktop application vs. Silverlight initiated network traffic.&lt;/p&gt;  &lt;h5&gt;Conclusion&lt;/h5&gt;  &lt;p&gt;For the time being, we’ve settled on the port range restrictions as the best compromise to maintain security and protect our customers. We understand this makes interoperability and connectivity challenging for some deployments, but we are planning to address that feedback with future work in this area.&lt;/p&gt;  &lt;p&gt;I hope this helps to clear up some of the questions out there about this, and if you have more, please let us know. Thanks!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9800123" width="1" height="1"&gt;</content><author><name>Aaron Oneal</name><uri>http://blogs.msdn.com/Aaron-Oneal-_5B00_MSFT_5D00_/ProfileUrlRedirect.ashx</uri></author><category term="Sockets" scheme="http://blogs.msdn.com/b/ncl/archive/tags/Sockets/" /><category term="Security" scheme="http://blogs.msdn.com/b/ncl/archive/tags/Security/" /><category term="Silverlight" scheme="http://blogs.msdn.com/b/ncl/archive/tags/Silverlight/" /></entry><entry><title>Custom HTTP Authentication Schemes</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/ncl/archive/2009/05/05/custom-http-authentication-schemes.aspx" /><id>http://blogs.msdn.com/b/ncl/archive/2009/05/05/custom-http-authentication-schemes.aspx</id><published>2009-05-05T21:06:00Z</published><updated>2009-05-05T21:06:00Z</updated><content type="html">&lt;h1 style="MARGIN: 24pt 0in 0pt"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: #4f81bd;"&gt;&lt;span style="font-family: Cambria;"&gt;Introduction&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;
&lt;p class="MsoNormal" style="TEXT-INDENT: 0.25in; MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;My name is Chris Ross and I work as a developer for Microsoft&amp;rsquo;s .NET Framework networking components.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;As part of the Network Class Library (NCL) team I get lots of networking questions from other developers.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;This post resulted from my research into a question about using custom HTTP authentication schemes.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;The custom scheme in question was Google&amp;rsquo;s GoogleLogin scheme, so I&amp;rsquo;ll use it as an example to show how System.Net.WebRequest and System.Net.WebClient can work with custom schemes.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Fist though, I should explain how standard HTTP authentication works.&lt;/span&gt;&lt;/p&gt;
&lt;h2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;span style="font-family: Cambria; color: #4f81bd; font-size: medium;"&gt;Standard HTTP Authentication&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoNormal" style="TEXT-INDENT: 0.25in; MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;It has become increasingly important to secure online information from unauthorized users.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;But once secured, how do clients figure out how to login?&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Well, the HTTP protocol utilizes a back and forth negotiation pattern to let the client know that something is secured and what type of credentials they must submit to gain access.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="TEXT-INDENT: 0.25in; MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;A common HTTP authentication pattern goes as follows:&lt;/span&gt;&lt;/p&gt;
&lt;table cellpadding="0" cellspacing="0" border="1" class="MsoNormalTable" style="margin: auto auto auto 4.65pt; width: 529px; border-collapse: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext;"&gt;
&lt;tbody&gt;
&lt;tr style="height: 15.65pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes;"&gt;
&lt;td width="343" valign="bottom" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 257.25pt; padding-right: 5.4pt; height: 15.65pt; padding-top: 0in; mso-border-alt: solid windowtext .5pt; border: windowtext 1pt solid;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;WebRequest.Credentials = new&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;NetworkCredential(username, password);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="49" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 36.45pt; padding-right: 5.4pt; height: 15.65pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td width="137" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 103.05pt; padding-right: 5.4pt; height: 15.65pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 15.65pt; mso-yfti-irow: 1;"&gt;
&lt;td width="343" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 257.25pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;WebRequest sent (without Credentials)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="49" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 36.45pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;To&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="137" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 103.05pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;Secured web page&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 15.65pt; mso-yfti-irow: 2;"&gt;
&lt;td width="343" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 257.25pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;Error 401 &amp;ndash; List of login schemes supported &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;(Basic, Digest&amp;hellip;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="49" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 36.45pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;From&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="137" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 103.05pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;Secured web page&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 15.65pt; mso-yfti-irow: 3;"&gt;
&lt;td width="343" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 257.25pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;WebRequest +Credentials (formatted according &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;to the selected login scheme) sent&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="49" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 36.45pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;To&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="137" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 103.05pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;Secured web page&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 15.65pt; mso-yfti-irow: 4; mso-yfti-lastrow: yes;"&gt;
&lt;td width="343" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 257.25pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;200 &amp;ndash; Success &amp;ndash; Here is your secured content&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="49" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 36.45pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;From&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="137" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 103.05pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;Secured web page&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p class="MsoListParagraph" style="MARGIN: 0in 0in 10pt 0.5in"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="TEXT-INDENT: 0.25in; MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;The best part is that .NET handles this back and forth for you under the hood, so all you end up seeing is the content you asked for.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;The .NET Framework (WebClient &amp;amp; WebRequest) has built in support for Basic, Digest, NTLM, Kerberos, and Negotiate authentication schemes.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="TEXT-INDENT: 0.25in; MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;Here is an example on how you would use standard authentication schemes with WebRequest:&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;public&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; NormalHTTPAuthExample(&lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; username, &lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; password)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;NetworkCredential&lt;/span&gt; creds = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;NetworkCredential&lt;/span&gt;(username, password);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;WebRequest&lt;/span&gt; request = &lt;span style="COLOR: #2b91af"&gt;WebRequest&lt;/span&gt;.Create(&lt;span style="COLOR: #a31515"&gt;"http://www.contoso.com/"&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;request.Credentials = creds; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// Send the request and process the response&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;WebResponse&lt;/span&gt; response = request.GetResponse();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;StreamReader&lt;/span&gt; responseStreamReader =&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;StreamReader&lt;/span&gt;(response.GetResponseStream());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; result = responseStreamReader.ReadToEnd();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;responseStreamReader.Close();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(result);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: #4f81bd;"&gt;&lt;span style="font-family: Cambria;"&gt;WebRequest Authentication Practices&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoNormal" style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;WebRequest takes great care with the credentials you provided.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Many of these precautions are to help prevent your username and password from being exposed to unauthorized servers.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Two features related to our example are CredentialCache and PreAuthenticate.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;WebRequest by default facilitates automatic request redirection from site to site.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;However if a server you have logged into decides to redirect you elsewhere, WebRequest will remove its Credentials property before automatically redirecting to prevent your username and password from being exposed.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;If you are aware that redirects will take place, you can use the CredentialCache class to manage what servers are allowed access to your credentials. &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;A CredentialCache pairs credentials with the URIs and authentication schemes they&amp;rsquo;re allowed to be used with.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;When you have created and configured a CredentialCache object, you then assign it to the WebRequest.Credentials property.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;You can see this in the next code sample.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;A CredentialCache will not be removed from the Credentials property when redirecting because WebRequest knows where you will allow your credentials sent.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;You may also reuse your cache by assigning it to subsequent requests.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;All of this also applies to WebClient.Credentials, as it uses WebRequest for its underlying operations.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;A second WebRequest property that can be useful with HTTP authentication is PreAuthenticate.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Without it, WebRequest will not include your credentials on a request until it has first received a challenge from the server.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Setting this property is optional but will help boost performance on secured sites as follows.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;After you&amp;rsquo;ve successfully authenticated once, this flag causes your credentials to be included in the Authorization header automatically on subsequent requests and redirects that match the same URI path at the folder level.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;This way the server does not have to issue a challenge for authentication on each page.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;WebClient does not expose this property.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;Here is a code sample that shows both of these properties:&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;public&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; RedirectHTTPAuthExample(&lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; username, &lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; password)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;NetworkCredential&lt;/span&gt; creds = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;NetworkCredential&lt;/span&gt;(username, password);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;CredentialCache&lt;/span&gt; credCache = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;CredentialCache&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// Cached credentials can only be used when requested by &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// specific URLs and authorization schemes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;credCache.Add(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Uri&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"http://www.contoso.com/"&lt;/span&gt;), &lt;span style="COLOR: #a31515"&gt;"Basic"&lt;/span&gt;, creds);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;WebRequest&lt;/span&gt; request = &lt;span style="COLOR: #2b91af"&gt;WebRequest&lt;/span&gt;.Create(&lt;span style="COLOR: #a31515"&gt;"http://www.contoso.com/"&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// Must be a cache, basic credentials are cleared on redirect&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;request.Credentials = credCache;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;request.PreAuthenticate = &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;; &lt;span style="COLOR: green"&gt;// More efficient, but optional&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;WebResponse&lt;/span&gt; response = request.GetResponse();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;StreamReader&lt;/span&gt; responseStreamReader =&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;StreamReader&lt;/span&gt;(response.GetResponseStream());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; result = responseStreamReader.ReadToEnd();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;responseStreamReader.Close();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(result);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;span style="font-family: Cambria; color: #4f81bd; font-size: medium;"&gt;Custom HTTP Authentication Schemes&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoNormal" style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;What if the sever you&amp;rsquo;re requesting information from does not utilize one of the standard authentication schemes?&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Take for an example Google&amp;rsquo;s custom GoogleLogin authentication scheme.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;I&amp;rsquo;m no expert on Google&amp;rsquo;s APIs, but its differences from standard HTTP authentication schemes make for a good example.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;GoogleLogin requires first making a request to a completely different login server for an Auth token, then adding that token to every subsequent request&amp;rsquo;s Authorization header.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;You can still do this with .NET, but because GoogleLogin is a custom scheme you might have to handle some of the back and forth yourself, such as turning off automatic redirects so you can be sure to include the Auth token on each request. &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;For example, you would first make a request to the login server for your user token.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Then you&amp;rsquo;d add that token to a second request to the Calendar server.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;The Calendar server responds with a redirect to your specific calendar at a session specific url.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;You then issue one final request (again including the Auth token) to that session specific url for your calendar data.&lt;/span&gt;&lt;/p&gt;
&lt;table cellpadding="0" cellspacing="0" border="1" class="MsoNormalTable" style="margin: auto auto auto 4.65pt; width: 535px; border-collapse: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext;"&gt;
&lt;tbody&gt;
&lt;tr style="height: 15.65pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes;"&gt;
&lt;td width="307" valign="bottom" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 230.25pt; padding-right: 5.4pt; height: 15.65pt; padding-top: 0in; mso-border-alt: solid windowtext .5pt; border: windowtext 1pt solid;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;WebRequest (with user name and password) sent&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="54" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 40.5pt; padding-right: 5.4pt; height: 15.65pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;To&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="174" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 130.5pt; padding-right: 5.4pt; height: 15.65pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;Login server&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 15.65pt; mso-yfti-irow: 1;"&gt;
&lt;td width="307" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 230.25pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;Auth token&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="54" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 40.5pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;From&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="174" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 130.5pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;Login server&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 15.65pt; mso-yfti-irow: 2;"&gt;
&lt;td width="307" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 230.25pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;WebRequest + Auth token&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="54" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 40.5pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;To&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="174" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 130.5pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;Secured Calendar server&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 15.65pt; mso-yfti-irow: 3;"&gt;
&lt;td width="307" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 230.25pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;302 &amp;ndash; Redirect to session specific URL&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="54" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 40.5pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;From&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="174" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 130.5pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;Secured Calendar server&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 15.65pt; mso-yfti-irow: 4;"&gt;
&lt;td width="307" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 230.25pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;WebRequest + Auth token sent to new URL&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="54" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 40.5pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;To&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="174" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 130.5pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;Your Secured Calendar&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 15.65pt; mso-yfti-irow: 5; mso-yfti-lastrow: yes;"&gt;
&lt;td width="307" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 230.25pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;200 &amp;ndash; Success &amp;ndash; Here is your secured content&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="54" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 40.5pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;From&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="174" valign="bottom" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 130.5pt; padding-right: 5.4pt; height: 15.65pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: black; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;span style="font-family: Calibri;"&gt;Your Secured Calendar&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p class="MsoNormal" style="TEXT-INDENT: 0.25in; MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;While this approach can work well enough to use once, I find it unwieldy to make three different requests where only one would normally be required, especially if you needed to do it often.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;Luckily .NET provides a better answer to this sort of problem: Custom Authentication Modules.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;You can add your own modules to the list of supported authentication schemes for WebClient &amp;amp; WebRequest, and let .NET juggle the authentication, redirection, proxies, and other complications for you.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Below is an example of how to do this for Google&amp;rsquo;s custom GoogleLogin scheme.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;span style="font-family: Cambria; color: #4f81bd; font-size: medium;"&gt;How to use a custom module with WebRequest/WebClient&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;How do we use WebRequest and a custom authentication module to log in to Google services?&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Here is a sample:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;public&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; GoogleAuthManagerExample(&lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; username, &lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; password)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;AuthenticationManager&lt;/span&gt;.Register(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;GoogleLoginClient&lt;/span&gt;()); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// Now 'GoogleLogin' is a recognized authentication scheme&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;GoogleCredentials&lt;/span&gt; creds = &lt;span style="COLOR: green"&gt;// user@gmail.com&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;GoogleCredentials&lt;/span&gt;(username, password, &lt;span style="COLOR: #a31515"&gt;"HOSTED_OR_GOOGLE"&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;CredentialCache&lt;/span&gt; credCache = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;CredentialCache&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// Cached credentials can only be used when requested by &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// specific URLs and authorization schemes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;credCache.Add(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Uri&lt;/span&gt;(&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;"http://www.google.com/calendar/feeds/default/private/"&lt;/span&gt;), &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;"GoogleLogin"&lt;/span&gt;, creds);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;WebRequest&lt;/span&gt; request = &lt;span style="COLOR: #2b91af"&gt;WebRequest&lt;/span&gt;.Create( &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;"http://www.google.com/calendar/feeds/default/private/full?q=null+item"&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// Must be a cache, basic credentials are cleared on redirect&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;request.Credentials = credCache; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;request.PreAuthenticate = &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;; &lt;span style="COLOR: green"&gt;// More efficient, but optional&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;WebResponse&lt;/span&gt; response = request.GetResponse();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;StreamReader&lt;/span&gt; responseStreamReader = &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;StreamReader&lt;/span&gt;(response.GetResponseStream());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; result = responseStreamReader.ReadToEnd();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;responseStreamReader.Close();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(result);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// Erase cached auth token unless you'll use it again soon.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;creds.PrevAuth = &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;The only meaningful difference between this code block and the previous authentication example I showed is the registration of the GoogleLoginClient.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;The GoogleLoginClient is a custom authentication module that WebRequest can refer to for handling the special symantics of Google&amp;rsquo;s API.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;As I described before, the alternative is to include much of the folowing Google API code inline, as well as managing all of your own redirection.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;I definitely prefer the custom modules, so lets look how to implement this custom authentication module.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;span style="font-family: Cambria; color: #4f81bd; font-size: medium;"&gt;How to write a custom authentication module for GoogleLogin&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoNormal" style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;The first minor element is a storage place for Google&amp;rsquo;s Auth token and login parameters.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Caching the token is ok so long as you&amp;rsquo;re careful where you put it and you know when you need to clear it.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;public&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;GoogleCredentials&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;NetworkCredential&lt;/span&gt; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Authorization&lt;/span&gt; prevAuth = &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Authorization&lt;/span&gt; PrevAuth { &lt;span style="COLOR: green"&gt;// Cached login token&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;get&lt;/span&gt; { &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; prevAuth; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;set&lt;/span&gt; { prevAuth = &lt;span style="COLOR: blue"&gt;value&lt;/span&gt;; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; accountType; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; AccountType {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;get&lt;/span&gt; { &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; accountType; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// Validate "GOOGLE","HOSTED", or "HOSTED_OR_GOOGLE"&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;set&lt;/span&gt; { accountType = &lt;span style="COLOR: blue"&gt;value&lt;/span&gt;; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; GoogleCredentials(&lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; user, &lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; pswd, &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String&lt;/span&gt; accountType) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;: &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;(user, pswd) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.AccountType = accountType;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-no-proof: yes"&gt;Then we need to implement the IAuthenticationModule interface.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;When we are challenged for GoogleLogin authorization this will do the actual request to Google&amp;rsquo;s login server and fetch us an Auth token.&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNoSpacing" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;public&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;GoogleLoginClient&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;IAuthenticationModule&lt;/span&gt; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;internal&lt;/span&gt; &lt;span style="COLOR: blue"&gt;const&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; AuthType = &lt;span style="COLOR: #a31515"&gt;"GoogleLogin"&lt;/span&gt;; &lt;span style="COLOR: green"&gt;// Scheme identifier&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;internal&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; AuthServer&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;= &lt;span style="COLOR: #a31515"&gt;"https://www.google.com/accounts/ClientLogin"&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; ServiceString = &lt;span style="COLOR: #a31515"&gt;"cl"&lt;/span&gt;; &lt;span style="COLOR: green"&gt;// Calendar&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; Source = &lt;span style="COLOR: #a31515"&gt;"MSTest"&lt;/span&gt;; &lt;span style="COLOR: green"&gt;// Our program name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Authorization&lt;/span&gt; Authenticate(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; challenge, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;WebRequest&lt;/span&gt; webRequest, &lt;span style="COLOR: #2b91af"&gt;ICredentials&lt;/span&gt; credentials) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// Careful, if your challenge contains more than one &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// authorization scheme, this one might not be first &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// in the list. Also ignore parameter names and quoted &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// parameter values.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;See RFC 2617 Section 1.2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// ie: Basic, Digest nonce=122352354,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;realm="www.GoogleLoginDirections.com/help",&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;GoogleLogin realm="http://login.google.com/",Ntlm&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (!challenge.Contains(AuthType) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;/* &amp;amp;&amp;amp; ContainsNotInQuotes(challenege,AuthType)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;* &amp;amp;&amp;amp; MoreValidation(challenege,AuthType) */&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; Login(webRequest, credentials);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Authorization&lt;/span&gt; PreAuthenticate(&lt;span style="COLOR: #2b91af"&gt;WebRequest&lt;/span&gt; webRequest, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;ICredentials&lt;/span&gt; credentials) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; Login(webRequest, credentials);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; CanPreAuthenticate {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// Some schemes do not support PreAuthentication&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;get&lt;/span&gt; { &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; AuthenticationType {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;get&lt;/span&gt; { &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; AuthType; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Authorization&lt;/span&gt; Login(&lt;span style="COLOR: #2b91af"&gt;WebRequest&lt;/span&gt; webRequest, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;ICredentials&lt;/span&gt; credentials) { &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// Do we have credentials for this site?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;NetworkCredential&lt;/span&gt; NC = credentials.GetCredential(&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;webRequest.RequestUri, AuthType);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;GoogleCredentials&lt;/span&gt; gcreds = NC &lt;span style="COLOR: blue"&gt;as&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;GoogleCredentials&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (gcreds == &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;; &lt;span style="COLOR: green"&gt;// none or wrong type of credentials&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (gcreds.PrevAuth != &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; gcreds.PrevAuth; &lt;span style="COLOR: green"&gt;// Cached from last login&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;ICredentialPolicy&lt;/span&gt; policy = &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: #2b91af"&gt;AuthenticationManager&lt;/span&gt;.CredentialPolicy;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (policy != &lt;span style="COLOR: blue"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; !policy.ShouldSendCredential(&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;webRequest.RequestUri, webRequest, NC, &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;WebRequest&lt;/span&gt; client = &lt;span style="COLOR: #2b91af"&gt;WebRequest&lt;/span&gt;.Create(AuthServer);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;client.ContentType = &lt;span style="COLOR: #a31515"&gt;"application/x-www-form-urlencoded"&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;client.Method = &lt;span style="COLOR: #a31515"&gt;"POST"&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// Custom authentication string: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR: green"&gt;// http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; requestParams = &lt;span style="COLOR: #a31515"&gt;"accountType="&lt;/span&gt; + gcreds.AccountType &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;+ &lt;span style="COLOR: #a31515"&gt;"&amp;amp;Email="&lt;/span&gt; + gcreds.UserName + &lt;span style="COLOR: #a31515"&gt;"&amp;amp;Passwd="&lt;/span&gt; + gcreds.Password &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;+ &lt;span style="COLOR: #a31515"&gt;"&amp;amp;service="&lt;/span&gt; + ServiceString + &lt;span style="COLOR: #a31515"&gt;"&amp;amp;source="&lt;/span&gt; + Source; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;[] bytes = &lt;span style="COLOR: #2b91af"&gt;Encoding&lt;/span&gt;.UTF8.GetBytes(requestParams);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// Google's API says that the custom authentication string &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// goes in the body of this request.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;This is unusual.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;Stream&lt;/span&gt; requestStream = client.GetRequestStream();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;requestStream.Write(bytes, 0, bytes.Length);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;requestStream.Close();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// The Auth token comes in the response body. Also unusual.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;WebResponse&lt;/span&gt; response = client.GetResponse();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;StreamReader&lt;/span&gt; responseStreamReader = &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;StreamReader&lt;/span&gt;(response.GetResponseStream());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; result = responseStreamReader.ReadToEnd();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;responseStreamReader.Close();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; authToken = &lt;span style="COLOR: #a31515"&gt;""&lt;/span&gt;; &lt;span style="COLOR: green"&gt;// Parse out the Auth token&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt;[] tokens = result.Split(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt;[] { &lt;span style="COLOR: #a31515"&gt;"\n"&lt;/span&gt; }, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;StringSplitOptions&lt;/span&gt;.None);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; token &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; tokens) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (token.StartsWith(&lt;span style="COLOR: #a31515"&gt;"Auth="&lt;/span&gt;, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;StringComparison&lt;/span&gt;.OrdinalIgnoreCase)) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;authToken = token;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;break&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (authToken == &lt;span style="COLOR: #a31515"&gt;""&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;throw&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;WebException&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"GoogleLogin authentication failed"&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// Assemble the Authorization header and cache it&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;gcreds.PrevAuth = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Authorization&lt;/span&gt;(AuthType + &lt;span style="COLOR: #a31515"&gt;" "&lt;/span&gt; + authToken);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; gcreds.PrevAuth;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;And you&amp;rsquo;re done.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Now any time your application is challenged for GoogleLogin authentication, WebRequest can just refer to this new module automatically.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: #4f81bd;"&gt;&lt;span style="font-family: Cambria;"&gt;Conclusions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;HTTP authentication can take many forms, and .NET includes support for several standard schemes.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;When these are not sufficient, it is easy to add custom schemes for many other services with minimal changes to your existing code.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;span style="font-family: Cambria; color: #4f81bd; font-size: medium;"&gt;Notes &amp;amp; references&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoListParagraphCxSpFirst" style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;-&lt;/span&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;WebClient: &lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;-&lt;/span&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;WebRequest: &lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;-&lt;/span&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-no-proof: yes; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;IAthenticationModule:&lt;/span&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-no-proof: yes; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;a href="http://msdn.microsoft.com/en-us/library/system.net.iauthenticationmodule.aspx"&gt;http://msdn.microsoft.com/en-us/library/system.net.iauthenticationmodule.aspx&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;-&lt;/span&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;Register a new custom module in the App.Config file without modifying existing code: &lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/y9b82x09(loband).aspx"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;http://msdn.microsoft.com/en-us/library/y9b82x09.aspx&lt;/span&gt;&lt;/a&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;-&lt;/span&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;CredentialCache: &lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.net.credentialcache.aspx"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;http://msdn.microsoft.com/en-us/library/system.net.credentialcache.aspx&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;-&lt;/span&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;GoogleLogin API: &lt;/span&gt;&lt;a href="http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html"&gt;&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;-&lt;/span&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;RFC 2617 &amp;ndash; HTTP Basic &amp;amp; Digest authentication - &lt;/span&gt;&lt;/span&gt;&lt;a href="http://www.ietf.org/rfc/rfc2617.txt"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;http://www.ietf.org/rfc/rfc2617.txt&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;-&lt;/span&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;RFC 2616 &amp;ndash; HTTP 1.1 - &lt;/span&gt;&lt;a href="http://www.ietf.org/rfc/rfc2616.txt"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;http://www.ietf.org/rfc/rfc2616.txt&lt;/span&gt;&lt;/a&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpLast" style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.5in; mso-list: l0 level1 lfo1"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-fareast-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;-&lt;/span&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;VB example:&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt; &lt;a href="http://support.microsoft.com/default.aspx/kb/331501"&gt;http://support.microsoft.com/default.aspx/kb/331501&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNoSpacing" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;~Chris Ross&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNoSpacing" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;System.Net&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9589380" width="1" height="1"&gt;</content><author><name>Tratcher</name><uri>http://blogs.msdn.com/chrross/ProfileUrlRedirect.ashx</uri></author><category term="Authentication" scheme="http://blogs.msdn.com/b/ncl/archive/tags/Authentication/" /><category term="HTTP" scheme="http://blogs.msdn.com/b/ncl/archive/tags/HTTP/" /><category term="WebRequest" scheme="http://blogs.msdn.com/b/ncl/archive/tags/WebRequest/" /><category term="WebClient" scheme="http://blogs.msdn.com/b/ncl/archive/tags/WebClient/" /></entry></feed>