<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Network Class Library Team (System.Net)</title><link>http://blogs.msdn.com/ncl/default.aspx</link><description /><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>UDP Multicast in Silverlight 4</title><link>http://blogs.msdn.com/ncl/archive/2009/11/18/udp-multicast-in-silverlight-4.aspx</link><pubDate>Wed, 18 Nov 2009 22:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9910206</guid><dc:creator>Aaron Oneal [MSFT]</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/ncl/comments/9910206.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ncl/commentrss.aspx?PostID=9910206</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/ncl/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/ncl/archive/tags/UDP/default.aspx">UDP</category><category domain="http://blogs.msdn.com/ncl/archive/tags/Multicast/default.aspx">Multicast</category></item><item><title>Visual Studio 2010 and .NET Framework 4 Beta 2 Released!</title><link>http://blogs.msdn.com/ncl/archive/2009/10/19/visual-studio-2010-and-net-framework-4-beta-2-released.aspx</link><pubDate>Mon, 19 Oct 2009 17:47:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9909264</guid><dc:creator>Aaron Oneal [MSFT]</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/ncl/comments/9909264.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ncl/commentrss.aspx?PostID=9909264</wfw:commentRss><description>&lt;p&gt;Grab the beta &lt;a href="http://go.microsoft.com/fwlink/?LinkID=151797"&gt;here&lt;/a&gt; and please be sure to send us feedback using &lt;a href="http://connect.microsoft.com/VisualStudio"&gt;Connect&lt;/a&gt;. Hope you enjoy the release!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9909264" width="1" height="1"&gt;</description></item><item><title>New Performance Counters for HttpWebRequest</title><link>http://blogs.msdn.com/ncl/archive/2009/08/07/new-performance-counters-for-httpwebrequest.aspx</link><pubDate>Sat, 08 Aug 2009 06:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9860753</guid><dc:creator>PeSmith</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/ncl/comments/9860753.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ncl/commentrss.aspx?PostID=9860753</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/ncl/archive/tags/Troubleshooting/default.aspx">Troubleshooting</category><category domain="http://blogs.msdn.com/ncl/archive/tags/HTTP/default.aspx">HTTP</category><category domain="http://blogs.msdn.com/ncl/archive/tags/.NET+Framework+4.0/default.aspx">.NET Framework 4.0</category></item><item><title>What's new in System.Net.Mail</title><link>http://blogs.msdn.com/ncl/archive/2009/08/06/what-s-new-in-system-net-mail.aspx</link><pubDate>Thu, 06 Aug 2009 23:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9859555</guid><dc:creator>jetucker</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/ncl/comments/9859555.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ncl/commentrss.aspx?PostID=9859555</wfw:commentRss><description>&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;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9859555" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ncl/archive/tags/New+Features/default.aspx">New Features</category><category domain="http://blogs.msdn.com/ncl/archive/tags/.NET+Framework+4.0/default.aspx">.NET Framework 4.0</category><category domain="http://blogs.msdn.com/ncl/archive/tags/SMTP/default.aspx">SMTP</category><category domain="http://blogs.msdn.com/ncl/archive/tags/System.Net.Mail/default.aspx">System.Net.Mail</category></item><item><title>End-to-end connectivity with NAT traversal</title><link>http://blogs.msdn.com/ncl/archive/2009/07/27/end-to-end-connectivity-with-nat-traversal-.aspx</link><pubDate>Mon, 27 Jul 2009 21:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9598006</guid><dc:creator>Aaron Oneal [MSFT]</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/ncl/comments/9598006.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ncl/commentrss.aspx?PostID=9598006</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/ncl/archive/tags/Teredo/default.aspx">Teredo</category><category domain="http://blogs.msdn.com/ncl/archive/tags/IPv6/default.aspx">IPv6</category><category domain="http://blogs.msdn.com/ncl/archive/tags/NAT+Traversal/default.aspx">NAT Traversal</category><category domain="http://blogs.msdn.com/ncl/archive/tags/Sockets/default.aspx">Sockets</category><category domain="http://blogs.msdn.com/ncl/archive/tags/.NET+Framework+4.0/default.aspx">.NET Framework 4.0</category></item><item><title>New NCL Features in .NET 4.0 Beta 2</title><link>http://blogs.msdn.com/ncl/archive/2009/07/20/new-ncl-features-in-net-4-0-beta-2.aspx</link><pubDate>Mon, 20 Jul 2009 18:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9834456</guid><dc:creator>Aaron Oneal [MSFT]</dc:creator><slash:comments>18</slash:comments><comments>http://blogs.msdn.com/ncl/comments/9834456.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ncl/commentrss.aspx?PostID=9834456</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/ncl/archive/tags/New+Features/default.aspx">New Features</category><category domain="http://blogs.msdn.com/ncl/archive/tags/.NET+Framework+4.0/default.aspx">.NET Framework 4.0</category></item><item><title>Why does Silverlight have a restricted port range for Sockets?</title><link>http://blogs.msdn.com/ncl/archive/2009/06/23/why-does-silverlight-have-a-restricted-port-range-for-sockets.aspx</link><pubDate>Tue, 23 Jun 2009 22:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9800123</guid><dc:creator>Aaron Oneal [MSFT]</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/ncl/comments/9800123.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ncl/commentrss.aspx?PostID=9800123</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/ncl/archive/tags/Sockets/default.aspx">Sockets</category><category domain="http://blogs.msdn.com/ncl/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/ncl/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Custom HTTP Authentication Schemes</title><link>http://blogs.msdn.com/ncl/archive/2009/05/05/custom-http-authentication-schemes.aspx</link><pubDate>Tue, 05 May 2009 21:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9589380</guid><dc:creator>chrross</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/ncl/comments/9589380.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ncl/commentrss.aspx?PostID=9589380</wfw:commentRss><description>&lt;H1 style="MARGIN: 24pt 0in 0pt"&gt;&lt;FONT size=4&gt;&lt;FONT color=#4f81bd&gt;&lt;FONT face=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;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H1&gt;
&lt;P style="TEXT-INDENT: 0.25in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;My name is Chris Ross and I work as a developer for Microsoft’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’s GoogleLogin scheme, so I’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;/FONT&gt;&lt;/P&gt;
&lt;H2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT color=#4f81bd size=4 face=Cambria&gt;Standard HTTP Authentication&lt;/FONT&gt;&lt;/H2&gt;
&lt;P style="TEXT-INDENT: 0.25in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=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;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.25in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;A common HTTP authentication pattern goes as follows:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;
&lt;TABLE style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; MARGIN: auto auto auto 4.65pt; WIDTH: 396.75pt; BORDER-COLLAPSE: collapse; BORDER-TOP: medium none; BORDER-RIGHT: medium none; 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" class=MsoNormalTable border=1 cellSpacing=0 cellPadding=0 width=529 class="MsoNormalTable"&gt;
&lt;TBODY&gt;
&lt;TR style="HEIGHT: 15.65pt; 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: 257.25pt; 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" vAlign=bottom width=343 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;WebRequest.Credentials = new NetworkCredential(username, password);&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;/SPAN&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: 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" vAlign=bottom width=49 noWrap&gt;&lt;FONT face=Calibri&gt;&lt;/FONT&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: 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" vAlign=bottom width=137 noWrap&gt;&lt;FONT face=Calibri&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15.65pt; 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: 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" vAlign=bottom width=343 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;WebRequest sent (without Credentials)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&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: 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" vAlign=bottom width=49 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;To&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&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: 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" vAlign=bottom width=137 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;Secured web page&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&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 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" vAlign=bottom width=343 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;Error 401 – List of login schemes supported (Basic, Digest…)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&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: 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" vAlign=bottom width=49 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;From&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&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: 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" vAlign=bottom width=137 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;Secured web page&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&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 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" vAlign=bottom width=343 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;WebRequest +Credentials (formatted according to the selected login scheme) sent&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&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: 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" vAlign=bottom width=49 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;To&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&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: 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" vAlign=bottom width=137 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;Secured web page&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&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 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" vAlign=bottom width=343 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;200 – Success – Here is your secured content&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&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: 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" vAlign=bottom width=49 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;From&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&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: 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" vAlign=bottom width=137 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;Secured web page&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.5in" class=MsoListParagraph&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;P style="TEXT-INDENT: 0.25in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&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;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.25in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Here is an example on how you would use standard authentication schemes with WebRequest:&lt;/FONT&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'; 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 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;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; &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 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;o:p&gt;&amp;nbsp;&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; &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 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; &lt;/SPAN&gt;request.Credentials = creds; &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; &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 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; &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 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; &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 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; &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 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; &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 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; &lt;/SPAN&gt;responseStreamReader.Close();&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; &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 style="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;H2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=4&gt;&lt;FONT color=#4f81bd&gt;&lt;FONT face=Cambria&gt;WebRequest Authentication Practices&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&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;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;/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;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’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;/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;&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’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;/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;Here is a code sample that shows both of these properties:&lt;/FONT&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'; 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 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;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; &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 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; &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 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; &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 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; &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 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; &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 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;o:p&gt;&amp;nbsp;&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; &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 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; &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 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; &lt;/SPAN&gt;request.Credentials = credCache;&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; &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 style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&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 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; &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 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; &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 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; &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 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; &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 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; &lt;/SPAN&gt;responseStreamReader.Close();&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; &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 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;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT color=#4f81bd size=4 face=Cambria&gt;Custom HTTP Authentication Schemes&lt;/FONT&gt;&lt;/H2&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;What if the sever you’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’s custom GoogleLogin authentication scheme.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I’m no expert on Google’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’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;/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;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’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;/FONT&gt;&lt;/P&gt;
&lt;P&gt;
&lt;TABLE style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; MARGIN: auto auto auto 4.65pt; WIDTH: 401.25pt; BORDER-COLLAPSE: collapse; BORDER-TOP: medium none; BORDER-RIGHT: medium none; 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" class=MsoNormalTable border=1 cellSpacing=0 cellPadding=0 width=535 class="MsoNormalTable"&gt;
&lt;TBODY&gt;
&lt;TR style="HEIGHT: 15.65pt; 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: 230.25pt; 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" vAlign=bottom width=307 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;WebRequest (with user name and password) sent&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&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: 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" vAlign=bottom width=54 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;To&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&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: 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" vAlign=bottom width=174 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;Login server&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&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 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" vAlign=bottom width=307 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;Auth token&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&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: 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" vAlign=bottom width=54 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;From&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&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: 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" vAlign=bottom width=174 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;Login server&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&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 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" vAlign=bottom width=307 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;WebRequest + Auth token&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&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: 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" vAlign=bottom width=54 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;To&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&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: 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" vAlign=bottom width=174 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;Secured Calendar server&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&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 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" vAlign=bottom width=307 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;302 – Redirect to session specific URL&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&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: 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" vAlign=bottom width=54 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;From&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&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: 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" vAlign=bottom width=174 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;Secured Calendar server&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&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 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" vAlign=bottom width=307 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;WebRequest + Auth token sent to new URL&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&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: 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" vAlign=bottom width=54 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;To&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&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: 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" vAlign=bottom width=174 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;Your Secured Calendar&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&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 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" vAlign=bottom width=307 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;200 – Success – Here is your secured content&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&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: 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" vAlign=bottom width=54 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;From&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&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: 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" vAlign=bottom width=174 noWrap&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&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;FONT face=Calibri&gt;Your Secured Calendar&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.25in; MARGIN: 0in 0in 10pt" 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;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&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;/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;&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’s custom GoogleLogin scheme.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT color=#4f81bd size=4 face=Cambria&gt;How to use a custom module with WebRequest/WebClient&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;&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;/FONT&gt;&lt;/FONT&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'; 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 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;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; &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 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; &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 style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&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 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; &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 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; &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 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; &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 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; &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 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; &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 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; &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 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; &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 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; &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 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;o:p&gt;&amp;nbsp;&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; &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 style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&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 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; &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 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; &lt;/SPAN&gt;request.Credentials = credCache; &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; &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 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; &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; &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 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; &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 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; &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 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; &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 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; &lt;/SPAN&gt;responseStreamReader.Close();&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; &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 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; &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 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; &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 style="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;SPAN style="mso-no-proof: yes"&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;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’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;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT color=#4f81bd size=4 face=Cambria&gt;How to write a custom authentication module for GoogleLogin&lt;/FONT&gt;&lt;/H2&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;The first minor element is a storage place for Google’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’re careful where you put it and you know when you need to clear it.&lt;/FONT&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'; 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 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; &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 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; &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 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; &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 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; &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 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; &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; &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 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; &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 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; &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 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; &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 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; &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 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; &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; &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 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="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 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; &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 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; &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 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; &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;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=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’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;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&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'; 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 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; &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 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; &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 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; &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 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; &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 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; &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 style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&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 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; &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 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; &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 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; &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 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; &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 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; &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 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; &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 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; &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 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; &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 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; &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 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; &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 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;&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 style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&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 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;&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 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; &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; &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 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; &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;o:p&gt;&amp;nbsp;&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; &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 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; &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 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; &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 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; &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;o:p&gt;&amp;nbsp;&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; &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 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; &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 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; &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 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; &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;o:p&gt;&amp;nbsp;&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; &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 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; &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 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; &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;o:p&gt;&amp;nbsp;&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; &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 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; &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 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; &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 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; &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 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;&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 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; &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 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; &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 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;&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 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; &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 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;&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 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; &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="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 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;&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 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; &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 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;&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 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;&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 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;o:p&gt;&amp;nbsp;&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; &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 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; &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 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; &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 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;o:p&gt;&amp;nbsp;&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; &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 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;&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 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; &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 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;&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 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;&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 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; &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 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; &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 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; &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 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; &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 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; &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 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; &lt;/SPAN&gt;requestStream.Close();&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; &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 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; &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 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; &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 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;&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 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; &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 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; &lt;/SPAN&gt;responseStreamReader.Close();&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;o:p&gt;&amp;nbsp;&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; &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 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; &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 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;&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 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; &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 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;&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 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;&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 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;&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 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;&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 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;&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; &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; &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 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;&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 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; &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 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; &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 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; &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 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; &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;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;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="mso-no-proof: yes"&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;And you’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;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=4&gt;&lt;FONT color=#4f81bd&gt;&lt;FONT face=Cambria&gt;Conclusions&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&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;&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;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT color=#4f81bd size=4 face=Cambria&gt;Notes &amp;amp; references&lt;/FONT&gt;&lt;/H2&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpFirst&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;FONT size=3 face=Calibri&gt;-&lt;/FONT&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;FONT size=3 face=Calibri&gt;WebClient: &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx"&gt;&lt;FONT size=3 face=Calibri&gt;http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle&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;FONT size=3 face=Calibri&gt;-&lt;/FONT&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;FONT size=3 face=Calibri&gt;WebRequest: &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx"&gt;&lt;FONT size=3 face=Calibri&gt;http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle&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;FONT size=3 face=Calibri&gt;-&lt;/FONT&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;FONT size=3 face=Calibri&gt;IAthenticationModule:&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-no-proof: yes; mso-bidi-theme-font: minor-latin"&gt;&lt;FONT size=3 face=Calibri&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;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle&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;FONT size=3 face=Calibri&gt;-&lt;/FONT&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;FONT size=3 face=Calibri&gt;Register a new custom module in the App.Config file without modifying existing code: &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/y9b82x09(loband).aspx" mce_href="http://msdn.microsoft.com/en-us/library/y9b82x09(loband).aspx"&gt;&lt;FONT size=3 face=Calibri&gt;http://msdn.microsoft.com/en-us/library/y9b82x09.aspx&lt;/FONT&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 style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle&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;FONT size=3 face=Calibri&gt;-&lt;/FONT&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;FONT size=3 face=Calibri&gt;CredentialCache: &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/system.net.credentialcache.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.credentialcache.aspx"&gt;&lt;FONT size=3 face=Calibri&gt;http://msdn.microsoft.com/en-us/library/system.net.credentialcache.aspx&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle&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;FONT size=3 face=Calibri&gt;-&lt;/FONT&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;FONT size=3 face=Calibri&gt;GoogleLogin API: &lt;/FONT&gt;&lt;A href="http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html" mce_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 style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle&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;FONT size=3 face=Calibri&gt;-&lt;/FONT&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;FONT size=3 face=Calibri&gt;RFC 2617 – HTTP Basic &amp;amp; Digest authentication - &lt;/FONT&gt;&lt;/SPAN&gt;&lt;A href="http://www.ietf.org/rfc/rfc2617.txt" mce_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;FONT size=3 face=Calibri&gt;http://www.ietf.org/rfc/rfc2617.txt&lt;/FONT&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 style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle&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;FONT size=3 face=Calibri&gt;-&lt;/FONT&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;FONT size=3 face=Calibri&gt;RFC 2616 – HTTP 1.1 - &lt;/FONT&gt;&lt;A href="http://www.ietf.org/rfc/rfc2616.txt" mce_href="http://www.ietf.org/rfc/rfc2616.txt"&gt;&lt;FONT size=3 face=Calibri&gt;http://www.ietf.org/rfc/rfc2616.txt&lt;/FONT&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 style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpLast&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;FONT size=3 face=Calibri&gt;-&lt;/FONT&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;FONT size=3&gt;&lt;FONT face=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" mce_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;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;~Chris Ross&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;System.Net&lt;/FONT&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9589380" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ncl/archive/tags/Authentication/default.aspx">Authentication</category><category domain="http://blogs.msdn.com/ncl/archive/tags/HTTP/default.aspx">HTTP</category><category domain="http://blogs.msdn.com/ncl/archive/tags/WebRequest/default.aspx">WebRequest</category><category domain="http://blogs.msdn.com/ncl/archive/tags/WebClient/default.aspx">WebClient</category></item><item><title>Functional Areas of the Network Class Library</title><link>http://blogs.msdn.com/ncl/archive/2009/03/25/functional-areas-of-the-network-class-library.aspx</link><pubDate>Thu, 26 Mar 2009 01:51:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9508793</guid><dc:creator>Aaron Oneal [MSFT]</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/ncl/comments/9508793.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ncl/commentrss.aspx?PostID=9508793</wfw:commentRss><description>&lt;p&gt;If you are wondering exactly what is in the NCL, the diagram below should help. It’s a high-level roadmap of the key feature areas and components.&lt;/p&gt;  &lt;p&gt;As you can see, the NCL is a roll up of the &lt;b&gt;System.Net.*&lt;/b&gt; namespaces and the URI related classes in &lt;b&gt;System&lt;/b&gt;. &lt;/p&gt;  &lt;p&gt;Networking features include sockets, an HTTP client, an HTTP listener, an SMTP client, network adapter information, and peer-to-peer connectivity. Future articles will cover these areas in more detail.&lt;/p&gt;  &lt;p&gt;Would you like to see more features added? Add a suggestion using &lt;a href="https://connect.microsoft.com/VisualStudio"&gt;Microsoft Connect&lt;/a&gt; and tell us more about your scenarios! Be sure to mention NCL/System.Net so it can be routed to our team.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/ncl/WindowsLiveWriter/FunctionalAreasoftheNetworkClassLibrary_DEFB/NCL%20Assembly%20Composition%20Diagram%20for%20NetFx_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="NCL Assembly Composition Diagram for NetFx" border="0" alt="NCL Assembly Composition Diagram for NetFx" src="http://blogs.msdn.com/blogfiles/ncl/WindowsLiveWriter/FunctionalAreasoftheNetworkClassLibrary_DEFB/NCL%20Assembly%20Composition%20Diagram%20for%20NetFx_thumb.png" width="520" height="282" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9508793" width="1" height="1"&gt;</description></item><item><title>Code Patterns for Online/Offline Network Detection</title><link>http://blogs.msdn.com/ncl/archive/2009/03/24/code-patterns-for-online-offline-network-detection.aspx</link><pubDate>Tue, 24 Mar 2009 03:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9502912</guid><dc:creator>PeSmith</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/ncl/comments/9502912.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ncl/commentrss.aspx?PostID=9502912</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;In the last entry&amp;nbsp;I showed you why you should use the &lt;B style="mso-bidi-font-weight: normal"&gt;&lt;U&gt;NetworkChange.NetworkAddressChanged&lt;/U&gt;&lt;/B&gt; API to control when to check if your application is online or not.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If you didn’t read that article, go do it now – it will help you understand why online detection is hard, and why the network detection code is made the way it is.&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;FONT size=3 face=Calibri&gt;As with all code, there are certain code patterns you can use to organize your online detection code.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Using the patterns means you are more likely to write good code that works well; ignoring the patterns means you are more likely to write hard-to-maintain code that doesn’t quite work well enough. What are the good code patterns for online detection?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It turns out that there are at least three.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Like any good blogger, I’ve got clever names for all them:&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;&lt;B style="mso-bidi-font-weight: normal"&gt;A &lt;/B&gt;is for &lt;B style="mso-bidi-font-weight: normal"&gt;Ask the User&lt;/B&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 0.5in" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;B&lt;/B&gt; is for &lt;B style="mso-bidi-font-weight: normal"&gt;Before you Connect, Validate&lt;/B&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;&lt;B style="mso-bidi-font-weight: normal"&gt;C&lt;/B&gt; is for &lt;B style="mso-bidi-font-weight: normal"&gt;Constantly Check Results&lt;/B&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;Ask the User&lt;/B&gt; is good because sometimes users have information that you do not – for example, that an upstream router is back on line, or that they have entered (into another window) some token or bit of authorization.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;They also know that they are on an automatically-dialed connection, and that they pay by the minute, and that even if your program could connect, they really don’t want it to connect right now.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;(There are always stories nowadays of people who accidently turned on “international roaming” and were charged thousands of dollars of fees)&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;Before you Connect, Validate&lt;/B&gt; is simple: you check a known file on your server before any other activity.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You have to check the file when your application starts and when you get a callback from NetworkAddressChanged. Do not forget that you have to check the contents of the file, not just the status code! &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;There are several tricks to make sure that the file is truly from your server and not from a cache.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;First, it helps to add in a query on the URL that points to the file.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The query should be different each time (a GUID, perhaps, or a random number), and the file should include the query parameter.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;That way you can be fairly confident that there aren’t any caches trying to help you when you really don’t want them to.&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;Constantly Check Results&lt;/B&gt; means that you can try to download a file or resource any time – but that each time you do, check the results to make sure that it’s really a file from your server.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;After getting a valid response that isn’t from your server, you must be in something like the “Airport Coffee Shop” case – someone is returning data as if they are your server, but it’s not.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In this case, your application might start queuing up all of the network requests and then retry them when the network might be available (which, as always, you know because you get a callback from NetworkAddressChanged).&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;Each of these methods has advantages and disadvantages.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Asking the user all the time, for example, is a big thing to ask.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;However, please always consider this on a setup or preferences page.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Some users really do have to pay for bandwidth and will not be pleased with any application that goes onto the network without permission.&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;FONT size=3 face=Calibri&gt;The before you connect, validate code pattern is simple, but requires that you put a known file on your server.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It’s also a bit slower to detect network availability because it will also check before allowing an actual file to be transmitted.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Lastly, the network might change faster than the code responds, resulting in bad data being accepted as good data.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;The constantly check results pattern is more complicated to implement, and requires that you be able to validate each possible result – and that may not be possible.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;On the other hand, it’s recovers faster and generates less network traffic.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;MSDN documentation for the NetworkChange.NetworkAddressChanged event is at &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkchange.networkaddresschanged.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkchange.networkaddresschanged.aspx"&gt;&lt;FONT size=3 face=Calibri&gt;http://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkchange.networkaddresschanged.aspx&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;I gave a talk at Mix '09&amp;nbsp;about network detection and reachability: &lt;/FONT&gt;&lt;A href="http://videos.visitmix.com/MIX09/T78M" mce_href="http://videos.visitmix.com/MIX09/T78M"&gt;&lt;FONT size=3 face=Calibri&gt;http://videos.visitmix.com/MIX09/T78M&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; (also look at the slide deck—it has notes that go into more depth than the presentation).&amp;nbsp; The talk is for Silverlight 3 users, but it applies to both the full framework and the Silverlight framework.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9502912" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ncl/archive/tags/NetworkChange/default.aspx">NetworkChange</category><category domain="http://blogs.msdn.com/ncl/archive/tags/Offline/default.aspx">Offline</category></item><item><title>Online/Offline Network Detection with the .NET Framework</title><link>http://blogs.msdn.com/ncl/archive/2009/03/17/online-offline-network-detection-with-net-framework.aspx</link><pubDate>Tue, 17 Mar 2009 11:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9482210</guid><dc:creator>PeSmith</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/ncl/comments/9482210.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ncl/commentrss.aspx?PostID=9482210</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Imagine this: you have been working on your great New World Wide Web program.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Your very first customer tries it out on their new notebook computer -- perhaps one of those very cute tiny notebooks that people are buying everywhere.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;And then you get your first report back: “I tried it while walking down the street.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Every time I walked by a coffee shop, it failed horribly”.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This blog entry will tell you how to use&amp;nbsp;&lt;A title=NetworkChange.NetworkAddressChanged href="http://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkchange.networkaddresschanged.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkchange.networkaddresschanged.aspx"&gt;NetworkChange.NetworkAddressChanged&lt;/A&gt; to solve your problem.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;You have just been hit by the biggest problem in the world of occasionally-connected computing!&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Your application was fooled into thinking it was talking to your server – that it was online – that it could do something useful.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In reality, all it was talking to was the coffee shop, and all the coffee shop was saying was, “please enter the network access code on your receipt to enable networking at this location.”&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;What you need now is online detection, and what you most need to know about online detection is:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 0.5in"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;U&gt;You are online if you can connect to your server and you have validated the response&lt;/U&gt;&lt;/I&gt;&lt;U&gt;.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;You might be fooled into looking at the various .Net and native APIs that return a simple boolean that says if you are online or not.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Ignore those APIs!&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;They do not provide the answer you need.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Why not?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Well, there is an entire list of reasons: &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpFirst style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;They mostly say if you are on “a” network, not on “a useful” network or even the internet.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Merely being connected to a hub with power is enough for many of them to consider you to be connected.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;From my personal, hard-fought experience, network detection is an area where some hardware and drivers just do not work reliably.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I have even seen a case where configuring a network only worked with a Wizard – manual configuration resulting in a working network but broken online detection code.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;3.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Many places—for example, the coffee shops and airports – will advertise network connectivity to your computer. But until you enter a special code in your browser (or perform some other action, possibly involving money), the only data that will ever be returned is a request to enter that special code.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpLast style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;4.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Some people are on automatic dial-up connection where they pay by the minute.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The more modern version of this is the fancy cell-network connections where some data plans will charge by the kilobyte.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;People with these sorts of connections will be “on line” but will not appreciate your application using the network.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Instead, you have to write your own method that will try to connect to your server, and then check the answer.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;But wait!&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;When is a good time to check?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Well, when your application starts for sure. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;Other than that – hook up your code to &lt;B style="mso-bidi-font-weight: normal"&gt;&lt;U&gt;NetworkChange.NetworkAddressChanged&lt;/U&gt;&lt;/B&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Just make sure that if you are connecting to “your server”, but it is returning nonsense (like, “Welcome to the Airport Coffee Shop...”) then you have to throw in a timer and periodically retry.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;One last hint about NetworkAddressChanged– it returns more events than you might think.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;While testing code for these entries I saw that plugging and unplugging the network cable on my laptop resulted in multiple events being triggered.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;MSDN documentation for the NetworkChange.NetworkAddressChanged event is at &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkchange.networkaddresschanged.aspx"&gt;&lt;FONT face=Calibri size=3&gt;http://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkchange.networkaddresschanged.aspx&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Next up: code patterns to make detection easier.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9482210" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ncl/archive/tags/NetworkChange/default.aspx">NetworkChange</category><category domain="http://blogs.msdn.com/ncl/archive/tags/Offline/default.aspx">Offline</category></item><item><title>FtpWebRequest compile with extended comments</title><link>http://blogs.msdn.com/ncl/archive/2008/07/26/ftpwebrequest-compile-with-extended-comments.aspx</link><pubDate>Sat, 26 Jul 2008 11:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8773711</guid><dc:creator>mariya</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/ncl/comments/8773711.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ncl/commentrss.aspx?PostID=8773711</wfw:commentRss><description>&lt;p&gt;This is a&amp;nbsp;current compile of the team's existing blogs on FtpWebRequest.&amp;nbsp;I am going to update&amp;nbsp;it periodically with new blogs and links to interesting forum questions regarding FtpWebRequest.&amp;nbsp;If you find intersting topics&amp;nbsp;or have ideas&amp;nbsp;for new&amp;nbsp;topics that would benefit our customers do&amp;nbsp;not hesitate to contact&amp;nbsp;us.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;MSDN documentation:&amp;nbsp;&lt;br&gt;&lt;/b&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx"&gt;http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;FtpWebRequest Overivew:&lt;/b&gt; Here you will find the overview of the&amp;nbsp;FtpWebRequest programming model&amp;nbsp;in .Net Framework 2.0 and 3.5&lt;br&gt;&lt;a href="http://blogs.msdn.com/adarshk/archive/2004/09/13/229069.aspx" mce_href="http://blogs.msdn.com/adarshk/archive/2004/09/13/229069.aspx"&gt;http://blogs.msdn.com/adarshk/archive/2004/09/13/229069.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Sending FTP commands with FtpWebRequest&lt;br&gt;&lt;/b&gt;&lt;a href="http://blogs.msdn.com/mariya/archive/2008/07/26/ftpwebrequest-commands-and-how-they-work.aspx" mce_href="http://blogs.msdn.com/mariya/archive/2008/07/26/ftpwebrequest-commands-and-how-they-work.aspx"&gt;http://blogs.msdn.com/mariya/archive/2008/07/26/ftpwebrequest-commands-and-how-they-work.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ftp over SSL with FtpWebRequest&lt;br&gt;&lt;/b&gt;This is a full article on how FtpWebRequest implements FTP over SSL (FTPS) it works, how to validate the server certificate, how to assign your own certificate. Includes&amp;nbsp;samples&lt;br&gt;Note:&amp;nbsp;FTPS is different form SFTP. Currently FtpWebRequest does not support SFTP&lt;br&gt;&lt;a href="http://blogs.msdn.com/adarshk/archive/2005/04/22/410925.aspx" mce_href="http://blogs.msdn.com/adarshk/archive/2005/04/22/410925.aspx"&gt;http://blogs.msdn.com/adarshk/archive/2005/04/22/410925.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Sample code for parsing the response returned by FtpWebRequest&amp;nbsp;for ListDirectoryDetails method&lt;br&gt;&lt;/b&gt;&lt;a href="http://blogs.msdn.com/adarshk/archive/2004/09/15/230177.aspx" mce_href="http://blogs.msdn.com/adarshk/archive/2004/09/15/230177.aspx"&gt;http://blogs.msdn.com/adarshk/archive/2004/09/15/230177.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;How to resume broken file download with FtpWebRequest&lt;br&gt;&lt;/b&gt;&lt;a href="http://blogs.msdn.com/adarshk/archive/2004/12/01/273362.aspx" mce_href="http://blogs.msdn.com/adarshk/archive/2004/12/01/273362.aspx"&gt;http://blogs.msdn.com/adarshk/archive/2004/12/01/273362.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;How to change to the root directory with FtpWebRequest&lt;br&gt;&lt;/b&gt;This question has been posted on the forums several times. The short answer is: yes, you can change to the root directory if your server allows you to. Find how in the blog below&lt;br&gt;&lt;a href="http://blogs.msdn.com/mariya/archive/2006/03/06/544523.aspx" mce_href="http://blogs.msdn.com/mariya/archive/2006/03/06/544523.aspx"&gt;http://blogs.msdn.com/mariya/archive/2006/03/06/544523.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;WebException message vs. Response.StatusDescription on FtpWebRequest&lt;/b&gt;&lt;br&gt;&lt;a href="http://blogs.msdn.com/adarshk/archive/2005/05/04/414524.aspx" mce_href="http://blogs.msdn.com/adarshk/archive/2005/05/04/414524.aspx"&gt;http://blogs.msdn.com/adarshk/archive/2005/05/04/414524.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;FtpWebRequest: Does the slash matter?&lt;/b&gt;&lt;a href="http://blogs.msdn.com/mariya/archive/2006/06/15/632768.aspx" mce_href="http://blogs.msdn.com/mariya/archive/2006/06/15/632768.aspx"&gt;http://blogs.msdn.com/mariya/archive/2006/06/15/632768.aspx&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8773711" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ncl/archive/tags/FtpWebRequest/default.aspx">FtpWebRequest</category><category domain="http://blogs.msdn.com/ncl/archive/tags/FTP/default.aspx">FTP</category></item><item><title>How to troubleshoot your System.Net code</title><link>http://blogs.msdn.com/ncl/archive/2008/07/25/how-to-troubleshoot-your-system-net-code.aspx</link><pubDate>Sat, 26 Jul 2008 06:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8772815</guid><dc:creator>mariya</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/ncl/comments/8772815.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ncl/commentrss.aspx?PostID=8772815</wfw:commentRss><description>&lt;p&gt;&lt;b&gt;Sytem.Net tracing&lt;br&gt;&lt;/b&gt;One of the easiest ways is to use the built in System.Net tracing. It is a matter of&amp;nbsp;copiying a config&amp;nbsp;file to your machine and re-running your application.&amp;nbsp;Here is a very detailed article on how tracing works and&amp;nbsp;how to enable it.&lt;br&gt;&lt;a href="http://blogs.msdn.com/dgorti/archive/2005/09/18/471003.aspx" mce_href="http://blogs.msdn.com/dgorti/archive/2005/09/18/471003.aspx"&gt;http://blogs.msdn.com/dgorti/archive/2005/09/18/471003.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;NetMon capture&amp;nbsp;&lt;br&gt;&lt;/b&gt;The other way is to sniff the network traffic using NetMon, Ethereal, or etc. Here is how you can do it with NetMon&lt;br&gt;&lt;a href="http://blogs.msdn.com/dgorti/archive/2005/10/29/486887.aspx" mce_href="http://blogs.msdn.com/dgorti/archive/2005/10/29/486887.aspx"&gt;http://blogs.msdn.com/dgorti/archive/2005/10/29/486887.aspx&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8772815" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ncl/archive/tags/Troubleshooting/default.aspx">Troubleshooting</category><category domain="http://blogs.msdn.com/ncl/archive/tags/Tracing/default.aspx">Tracing</category><category domain="http://blogs.msdn.com/ncl/archive/tags/Network+Capture/default.aspx">Network Capture</category></item><item><title>Welcome to the Network Class Library (NCL) Team Blog</title><link>http://blogs.msdn.com/ncl/archive/2008/07/21/welcome-to-the-network-class-library-ncl-team-blog.aspx</link><pubDate>Tue, 22 Jul 2008 03:33:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8762836</guid><dc:creator>Aaron Oneal [MSFT]</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/ncl/comments/8762836.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ncl/commentrss.aspx?PostID=8762836</wfw:commentRss><description>&lt;P&gt;&lt;I&gt;Delivering your managed networking experience.&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;There is a chance that you have never heard about the NCL team and yet you’re using our components every day (most likely, right now while you’re reading this). How could this be?&lt;/P&gt;
&lt;P&gt;When you opened this page to read our blog, here is what happened under the covers:&lt;SPAN&gt; &lt;/SPAN&gt;The browser sent an HTTP web request and the server answered by sending back an HTTP web response; when those calls are executed using managed code, then you’re using our components. In fact, every time you download a file, access secure resources (via SSL), or access any other network resources using managed code (any .NET language), you’re using our features. If you’re working with ASP.NET and web services in IIS, without realizing it, you’re using our features in almost every call that you make.&lt;SPAN&gt; &lt;/SPAN&gt;In addition, if you’re writing or using Silverlight rich internet applications, you’re benefiting from our features (check out &lt;A href="http://www.silverlight.net/" mce_href="http://www.silverlight.net/"&gt;http://www.silverlight.net/&lt;/A&gt; to see how cool Silverlight is).&lt;/P&gt;
&lt;P&gt;&lt;I&gt;Who are we and what do we do?&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;We are developers, testers, program managers, and document writers who work together to give you an unmatched managed networking experience. We own the System.Net namespace(s), the System.Uri class, and core networking components for Silverlight and Windows Live Mesh. &lt;/P&gt;
&lt;P&gt;&lt;I&gt;Why our technology?&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;Because our technology is simpler, more secure, and more powerful.&lt;SPAN&gt; &lt;/SPAN&gt;We have dozens of classes that make it easy to perform a variety of tasks, including sending email, serving up a web page, retrieving a web page, creating a secure connection, and even gathering information about the networking capabilities of the computer your code is running on.&lt;/P&gt;
&lt;P&gt;Sending data over a network can be as simple as instantiating a TcpClient and connecting to a URI.&lt;SPAN&gt; &lt;/SPAN&gt;You can have your networking code up and running in minutes.&lt;SPAN&gt; &lt;/SPAN&gt;Need more control over your network stream than that?&lt;SPAN&gt; &lt;/SPAN&gt;Our layered approach allows flexibility; open a socket directly so that you can implement your protocols the way you need them.&lt;SPAN&gt; &lt;/SPAN&gt;The only limit is your own creativity.&lt;/P&gt;
&lt;P&gt;Furthermore, because you’re in a managed environment, you have all the power of that environment at your disposal.&lt;SPAN&gt; &lt;/SPAN&gt;Your code will work on both 32 and 64 bit platforms, we handle interoperability with COM and native libraries, and we even manage the memory for you.&lt;SPAN&gt; &lt;/SPAN&gt;With our technology, you can spend less time figuring out how to deliver solutions and more time actually delivering them.&lt;/P&gt;
&lt;P&gt;You can find more detailed technical information in our &lt;A href="http://msdn.microsoft.com/en-us/library/system.net.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.net.aspx"&gt;MSDN library documentation&lt;/A&gt; and &lt;A href="http://forums.msdn.microsoft.com/en-US/ncl/threads/" mce_href="http://forums.msdn.microsoft.com/en-US/ncl/threads/"&gt;community forum&lt;/A&gt;, and you can contact us using the e-mail link above. For feature requests and bug submissions, please use the &lt;A href="http://connect.microsoft.com/VisualStudio" mce_href="http://connect.microsoft.com/VisualStudio"&gt;Microsoft Connect&lt;/A&gt; website.&lt;/P&gt;
&lt;P&gt;Welcome to our blog and have fun reading our posts!&lt;/P&gt;
&lt;P&gt;- NCL Team&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8762836" width="1" height="1"&gt;</description></item></channel></rss>