<?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>Adarsh's blog : Net class library</title><link>http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx</link><description>Tags: Net class library</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Communicator Web Access AJAX Service SDK Released!!</title><link>http://blogs.msdn.com/adarshk/archive/2006/04/06/570424.aspx</link><pubDate>Fri, 07 Apr 2006 03:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:570424</guid><dc:creator>adarshk</dc:creator><slash:comments>11</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/570424.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=570424</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;FONT color=#000080 size=3&gt;If you are looking for adding cool instant messaging&amp;nbsp;and presence functionality to your web applications or simple C# applications, try out Communicator Web Access AJAX Service SDK, it already includes the sample code to get started. I will also keep posting quick code snippets here.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;FONT color=#000080 size=3&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;FONT color=#000080&gt;Quick Info from the SDK:&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;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;FONT face=Arial size=2&gt;Communicator Web Access AJAX Service is the application programming interface for Microsoft Office Communicator Web Access. Application developers can use it to create Communicator-compatible clients that allow users to manage and share presence information, to manage contacts and groups, to send and receive instant messages, and to search for users within an enterprise. Such clients can be a browser-based Web application (e.g., an ASP or ASP.NET application) or a standalone network application (e.g., a .NET executable). The client applications can be written in a wide range of programming languages including JavaScript, C#, Perl, C/C++, and the Visual Basic development system. Because the Communicator Web Access AJAX Service is based on the flexible &lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;&lt;st1:place w:st="on"&gt;&lt;st1:City w:st="on"&gt;AJAX&lt;/st1:City&gt;&lt;/st1:place&gt; programming model, the client applications are not limited to running on Microsoft Windows operating systems and can readily be deployed to desktop, laptop, or other devices.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;FONT size=2&gt;Download Link:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?familyid=A839967B-680F-41E6-99B4-F020319BBD88&amp;amp;displaylang=en"&gt;&lt;FONT size=2&gt;http://www.microsoft.com/downloads/details.aspx?familyid=A839967B-680F-41E6-99B4-F020319BBD88&amp;amp;displaylang=en&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="COLOR: #333333; FONT-FAMILY: 'Trebuchet MS'"&gt;&lt;EM&gt;&lt;FONT size=2&gt;This posting is provided "AS IS" with no warranties, and confers no rights&lt;/FONT&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=570424" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/UC/default.aspx">UC</category></item><item><title>You need to be careful about using event handler for NetworkChange</title><link>http://blogs.msdn.com/adarshk/archive/2005/11/29/498173.aspx</link><pubDate>Wed, 30 Nov 2005 05:14:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:498173</guid><dc:creator>adarshk</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/498173.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=498173</wfw:commentRss><description>&lt;P&gt;&lt;FONT color=#000000&gt;Actually the issue I am discussing here is in general true for any event handler.&amp;nbsp;.net event handler are&amp;nbsp;strong reference. In case of NetworkChange it become more important because both event handler on NetworkChange object are static handlers, so there life time is the lifetime of the process.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#000000&gt;For example&amp;nbsp;you may be using code like below for&amp;nbsp;registering an instace method of your&amp;nbsp;object as handler&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;NetworkAvailabilityChangedEventHandler&amp;nbsp; myHandler = new NetworkAvailabilityChangedEventHandler (myNetworkAvailabilityChangeHandler);&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#808080&gt;NetworkChange.NetworkAvailabilityChanged += myHandler;&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Then you should make sure&amp;nbsp;to unregister&amp;nbsp;event handler once you are done with this object, otherwise your object is not garbage and you will see a memory leak effect on your application&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;NetworkChange.NetworkAvailabilityChanged -= myHandler&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#000000&gt;Please note this cleanup code can not be put in finalizer (becuase object is not yet garbage), you need to explicitly call it. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#000000&gt;Another option is to go with some sort of weak delegate.&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=#000000&gt;.net frameworks still do not have any concept of Weak delegates, but there are some cool solutions developed for simulating&amp;nbsp;weakreference semantics, which will be very useful in this situation. These solution&amp;nbsp;mainly consider using a proxy object standing between your object and final object where you want to register events. Check the Greg's blog &lt;a href="http://blogs.msdn.com/greg_schechter/archive/2004/05/27/143605.aspx"&gt;Simulating “Weak Delegates” in the CLR &lt;/A&gt;for nice explanation and pictorial representation..&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;There are also some other slight&amp;nbsp;improvement versions of same solution&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.interact-sw.co.uk/iangblog/2004/06/06/weakeventhandler"&gt;Simulating Weak Delegates for EventHandler-like Delegates &lt;/A&gt;(Ian Grifiths)&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#000000&gt;&lt;A href="http://www.seedindustries.com/blog/x/2004_06_01_archive.html#108656795427367272"&gt;Weak Events &lt;/A&gt;(Xavier Musy)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080 size=2&gt;&lt;SPAN style="COLOR: #333333; FONT-FAMILY: 'Trebuchet MS'"&gt;&lt;EM&gt;&lt;FONT size=2&gt;This posting is provided "AS IS" with no warranties, and confers no rights&lt;/FONT&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=498173" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/.Net+Frameworks+2.0/default.aspx">.Net Frameworks 2.0</category></item><item><title>Use object pooling of byte arrays to prevent heap fragmentation in socket applications</title><link>http://blogs.msdn.com/adarshk/archive/2005/08/20/454022.aspx</link><pubDate>Sat, 20 Aug 2005 15:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:454022</guid><dc:creator>adarshk</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/454022.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=454022</wfw:commentRss><description>&lt;P&gt;When&amp;nbsp;you are worrking on&amp;nbsp;managed socket application and your application is very extensively&amp;nbsp;doing send/recieve on the socket, then&amp;nbsp;probably you need to care about understanding the heap management. Socket.Recieve or Socket.Send finally need to call the underlying native winsock API call to recieve the data on user specified buffer. Same is true for NetworkStream.Read and NetworkStream.Write calls, because these methods also finally got translated socket send and recieve.&lt;/P&gt;
&lt;P&gt;To make the native API call buffer need to pinned for I/O, these pinned buffer can not be moved when garbage collector is doing the work of cleaning up. If your application is using newly allocated buffer in slow network environment and application is doing multiple I/O call frequently then it is possible that you will&amp;nbsp;hit the problem of heap fragmentation. If fragmentation is small, you probably do not need to worry about it, but if heap&amp;nbsp;fragmentation is reaching more than 10% and you are seeing larger time spend on GC. You need to look into&amp;nbsp;some better techniques to elliminate the unnecessary pressure on GC. One possible solution is create a pool of buffer in the startup and use object pooiling to reuse them as needed. &lt;/P&gt;
&lt;P&gt;Check the maoni's blog entry&amp;nbsp;&lt;a href="http://blogs.msdn.com/maoni/archive/2004/12/19/327149.aspx"&gt;Using GC Efficiently – Part 3&lt;/A&gt; to understand more about pinning and effective usage of GC and other good tips.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;EM&gt;&lt;FONT color=#808080 size=2&gt;This posting is provided "AS IS" with no warranties, and confers no rights&lt;/FONT&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=454022" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/.Net+Frameworks+2.0/default.aspx">.Net Frameworks 2.0</category></item><item><title>WebException message vs. Response.StatusDescription on FtpWebRequest</title><link>http://blogs.msdn.com/adarshk/archive/2005/05/04/414524.aspx</link><pubDate>Wed, 04 May 2005 09:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:414524</guid><dc:creator>adarshk</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/414524.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=414524</wfw:commentRss><description>&lt;FONT size=3&gt;
&lt;P&gt;Recently one of the reader asked&amp;nbsp;an interesting question, he was using FtpWebRequest&amp;nbsp;with&amp;nbsp;MakeDirectory method, if directory already exist then application received the WebException with message.&lt;/FONT&gt;&lt;FONT size=2&gt;"The remote server returned an error: (550) File unavailable (e.g., file not found, no access).".&lt;/FONT&gt;&lt;FONT size=3&gt; This exception message appears to be very generic and not helping the user to figure out what causes this request to fail. The reason is exception messages are generally set by framework implementation, because they also need to be localized on different language versions.&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=3&gt;
&lt;P&gt;In such case if FtpWebRequest user want to diagnose and figure out why request actually failed, he could access the actual response message from server using &lt;/FONT&gt;&lt;FONT size=2&gt;((FtpWebResponse)e.Response).StatusDescription &lt;/FONT&gt;&lt;FONT size=3&gt;property. Your actual code would look like as below&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;try&lt;/FONT&gt;&lt;BR&gt;{&lt;/FONT&gt;&lt;BR&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp; .&amp;nbsp; . . . . .&amp;nbsp; .&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT size=2&gt;WebResponse response = request.GetResponse();&lt;/FONT&gt;&lt;BR&gt;&lt;FONT size=2&gt;&amp;nbsp;. . . . . . . . . .&lt;/FONT&gt;&lt;BR&gt;&lt;FONT size=2&gt;}&lt;/FONT&gt;&lt;BR&gt;&lt;FONT size=2&gt;catch(WebException e)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String status = ((FtpWebResponse)e.Response).StatusDescription;&lt;BR&gt;}&lt;/FONT&gt;&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080 size=2&gt;&lt;SPAN&gt;&lt;EM&gt;&lt;FONT size=2&gt;This posting is provided "AS IS" with no warranties, and confers no rights&lt;/FONT&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=414524" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/.Net+Frameworks+2.0/default.aspx">.Net Frameworks 2.0</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/FtpWebRequest/default.aspx">FtpWebRequest</category></item><item><title>Using FtpWebRequest to do FTP over SSL</title><link>http://blogs.msdn.com/adarshk/archive/2005/04/22/410925.aspx</link><pubDate>Fri, 22 Apr 2005 23:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:410925</guid><dc:creator>adarshk</dc:creator><slash:comments>31</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/410925.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=410925</wfw:commentRss><description>&lt;P&gt;Last few weeks we were busy to get Whidbey Beta-2 bits ready for release.&lt;/P&gt;
&lt;P&gt;If you are looking for some API where your&amp;nbsp;application could talk to a FTP server, which supports SSL. FtpWebRequest under System.Net namespace is your solution. Here I will just point to SSL specific features of the class&lt;/P&gt;
&lt;P&gt;Enabling FtpWebrequest to use Ssl is pretty simple, you just need to set EnableSsl flag before calling GetResponse() or GetRequestStream() on the FtpWebRequest object.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080 size=2&gt;FtpWebRequest request = WebRequest.Create(&lt;/FONT&gt;&lt;A href="ftp://myftpserver/dir/filename"&gt;&lt;FONT color=#808080 size=2&gt;ftp://myftpserver/dir/filename&lt;/FONT&gt;&lt;/A&gt;&lt;FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;);&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#808080&gt;request.Method = WebRequestMethods.Ftp.DownloadFile;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#808080&gt;request.EnableSsl = true; // Here you enabled request to use ssl instead of clear text&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#808080&gt;WebResponse response = request.GetResponse();&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Some people asked me why FtpWebRequest support "ftps:" protocol&amp;nbsp;based uri similar to "https:", the reason is there is no standard "ftps" scheme specified (yet) and ftp-over-ssl mechanism&amp;nbsp;actually does not demand dedicated port for ssl, you could&amp;nbsp;do it&amp;nbsp;on the same server port on which you are doing regular clear text ftp.&amp;nbsp;It depends on server configuration choice to force the SSL or allow both.&lt;/P&gt;
&lt;P&gt;Once you start doing Ftp over SSL there are two important things you will need to know&lt;/P&gt;
&lt;P&gt;&lt;FONT size=4&gt;Validating Server Certificate&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;If you were old WebRequest user, you might already know about using ServicePointManager.CertificatePolicy for https server certificate validation. In whidbey you will notice the compiler warning saying ServicePointManager.CertificatePolicy is obsolete and replaced with ServicePointManager.ServerCertificateValidationCallback which is delegate of type RemoteCertificateValidationDelegate. New delegate provide better programming model with all certificate errors reported in a single callback and you will also get instance of X509Chain object, which allow you to make decision on certificate chain.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT size=2&gt;ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(myCertificateValidation);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;&lt;FONT&gt;&lt;FONT color=#000000 size=2&gt;Actual method will look as below&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT&gt;&amp;nbsp;&amp;nbsp;&lt;FONT size=2&gt;public bool myCertificateValidation(Object sender, &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;X509Certificate cert, &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;X509Chain chain, &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SslPolicyErrors Errors)&lt;BR&gt;{ return&amp;nbsp;(certificate.GetName() == "my_trusted_name");&amp;nbsp;}; //Just an example, not real world scenaio&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;:) Another&amp;nbsp;additional advantage you can take with delegate is from anonymous method support of C# 2.0, especially if you have very simple 1-2 line certificateplicy to implement, see follwing example.&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;&lt;FONT size=2&gt;ServicePointManager.ServerCertificateValidationCallback = delegate(Object obj,&amp;nbsp;X509Certificate certificate,&amp;nbsp;X509Chain chain,&amp;nbsp;SslPolicyErrors errors)&amp;nbsp;&lt;BR&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;&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;&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;&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;&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ return&amp;nbsp;(certificate.GetName() == "my_trusted_name");&amp;nbsp;}; //Just an example, not real world scenaio&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=4&gt;Using Client Certificate&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Using Client certificate based authentication when connecting to&amp;nbsp;FTP-SSL is no different then existing HttpWebRequest. You just need to assign appropriate X509Certificate instance to the request object before making GetResponse() or GetRequestStream() call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080 size=2&gt;&lt;SPAN&gt;&lt;EM&gt;&lt;FONT size=2&gt;This posting is provided "AS IS" with no warranties, and confers no rights&lt;/FONT&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=410925" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/SSL/default.aspx">SSL</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/.Net+Frameworks+2.0/default.aspx">.Net Frameworks 2.0</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/FtpWebRequest/default.aspx">FtpWebRequest</category></item><item><title>Use NetworkInformation classes to get the list of listening ports on your machine</title><link>http://blogs.msdn.com/adarshk/archive/2005/03/14/395392.aspx</link><pubDate>Mon, 14 Mar 2005 19:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:395392</guid><dc:creator>adarshk</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/395392.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=395392</wfw:commentRss><description>&lt;p&gt;.Net frameworks 2.0 have new addition of Namespace, System.Net.NetworkInformation, it provide a number of interesting classes to extract the network related statistics and state of the machine, it pretty much provide most of the functionality which is&amp;nbsp;exposed by native IPHelper APIs. &lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p&gt;Earlier I had shown a simple example for getting network availbility event notification. Here is another simple 4 line example, where your application could check all the listening ports on the machine.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;using System;&lt;/span&gt;&lt;br /&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;using System.Net;&lt;/span&gt;&lt;br /&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;using System.Net.NetworkInformation;&lt;/span&gt;&lt;br /&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;public class Test&lt;/span&gt;&lt;br /&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public static void &lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;&lt;st1:place w:st="on"&gt;Main&lt;/st1:place&gt;()&lt;/span&gt;&lt;br /&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&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;IPGlobalProperties ipGlobal = IPGlobalProperties.GetIPGlobalProperties();&lt;/span&gt;&lt;br /&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&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;IPEndPoint[] connections = ipGlobal.GetActiveTcpListeners ( ) ;&lt;/span&gt;&lt;br /&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&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;foreach(IPEndPoint ipe in connections)&lt;/span&gt;&lt;br /&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("Listening IPEndPoint = "+ipe.Port);&lt;/span&gt;&lt;br /&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;}&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=395392" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/Software+Testing/default.aspx">Software Testing</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/.Net+Frameworks+2.0/default.aspx">.Net Frameworks 2.0</category></item><item><title>Client side certificate with strong key protection and WebServices</title><link>http://blogs.msdn.com/adarshk/archive/2005/02/17/375479.aspx</link><pubDate>Thu, 17 Feb 2005 21:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:375479</guid><dc:creator>adarshk</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/375479.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=375479</wfw:commentRss><description>&lt;P&gt;When you are writing application to run as service or middle tier, which is using client certificates. You should not enable strong key protection during certificate installation. &lt;/P&gt;
&lt;P&gt;Strong key protection is the way you are informing the system that whenever someone want to use this protected resource (client certifcate) then prompt me for the permission. In middle tier environment you really do not want this prompt, you really want to run your application unattended. In fact with .Net frameworks 1.1, SP1 you won't be able to use the certificate with strong key protection.&lt;/P&gt;
&lt;P&gt;Check the posting from Kevin W. Hammond about his experience on this issue&lt;/P&gt;
&lt;P&gt;&lt;a href="http://blogs.msdn.com/kevinha/archive/2005/02/15/373254.aspx"&gt;http://blogs.msdn.com/kevinha/archive/2005/02/15/373254.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080 size=2&gt;&lt;SPAN style="COLOR: #333333; FONT-FAMILY: 'Trebuchet MS'"&gt;&lt;EM&gt;&lt;FONT size=2&gt;This posting is provided "AS IS" with no warranties, and confers no rights&lt;/FONT&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=375479" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/SSL/default.aspx">SSL</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/HttpWebRequest/default.aspx">HttpWebRequest</category></item><item><title>You could help us on application compatibilty verification</title><link>http://blogs.msdn.com/adarshk/archive/2005/02/04/367184.aspx</link><pubDate>Fri, 04 Feb 2005 20:11:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:367184</guid><dc:creator>adarshk</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/367184.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=367184</wfw:commentRss><description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If you have an application build on .net frameworks 1.0 or .net frameworks 1.1, which is using System.Net classes. If you want to&amp;nbsp; make sure that your app works behaves as expected on 2.0 we could help.This would also enable you to contribute on our effort&amp;nbsp;for application compatibility verification and&amp;nbsp;make sure application works perfectly with 2.0 version of frameworks.&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face=Arial color=#a9a9a9 size=2&gt;&lt;SPAN&gt;Here are some basic requirements&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT color=#a9a9a9&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN&gt;a)&lt;FONT face="Times New Roman" size=1&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN&gt;You&amp;nbsp;are willing to share the app with us under NDA,&amp;nbsp;a&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#a9a9a9&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN&gt;pplication&amp;nbsp;should be&amp;nbsp;small to medium size that can be set up in less than a day on one or two machine&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=#a9a9a9&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN&gt;c)&lt;FONT face="Times New Roman" size=1&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Arial color=#a9a9a9 size=2&gt;&lt;SPAN&gt;Please note this effort should not be&amp;nbsp;considered as any&amp;nbsp;official guarantee for compatibility, we will do&amp;nbsp;best effort to&amp;nbsp;verify and tell,&amp;nbsp;if there is&amp;nbsp;any breaking changes&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face=Arial color=#a9a9a9 size=2&gt;&lt;SPAN&gt;&lt;FONT color=#808080 size=2&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial color=#a9a9a9 size=2&gt;&lt;SPAN&gt;&lt;FONT color=#808080 size=2&gt;&lt;SPAN&gt;&lt;EM&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face=Arial color=#a9a9a9 size=2&gt;&lt;SPAN&gt;&lt;FONT color=#808080 size=2&gt;&lt;SPAN&gt;&lt;EM&gt;&lt;FONT size=2&gt;This posting is provided "AS IS" with no warranties, and confers no rights&lt;/FONT&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=367184" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/General/default.aspx">General</category></item><item><title>Must watch MSDNTV shows on network programming</title><link>http://blogs.msdn.com/adarshk/archive/2005/01/21/358294.aspx</link><pubDate>Fri, 21 Jan 2005 21:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:358294</guid><dc:creator>adarshk</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/358294.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=358294</wfw:commentRss><description>&lt;P&gt;If you love working on network programming and curious to see the demo of upcoming network programming features in .Net frameworks 2.0,&amp;nbsp;you will love these&amp;nbsp;MSDN &amp;nbsp;TV shows&amp;nbsp;from our team.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Write Connected Applications Using System.Net&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;
&lt;DIV&gt;Learn how to write better connected apps with System.Net in Visual Studio 2005. Since VS 2003, we've significantly enhanced the System.Net class libraries to make writing connected apps easier with added support for FTP, SMTP protocols, and the ability to listen and respond to HTTP requests&lt;/DIV&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20050113NETDG/manifest.xml"&gt;http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20050113NETDG/manifest.xml&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What's New in .NET Remoting for .NET Framework 2.0&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;
&lt;DIV&gt;Matt Tavis shows some new features and code examples in .NET Remoting in .NET Framework 2.0, including the new IpcChannel, the secure TcpChannel, and Version Tolerant Serialization (VTS) to allow authors to version their types without breaking serialization. &lt;/DIV&gt;
&lt;DIV&gt;&lt;A href="http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20050120NETMT/manifest.xml"&gt;http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20050120NETMT/manifest.xml&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=358294" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/General/default.aspx">General</category></item><item><title>Understanding HttpWebRequest Connection Management and ServicepointManager</title><link>http://blogs.msdn.com/adarshk/archive/2005/01/02/345413.aspx</link><pubDate>Sun, 02 Jan 2005 10:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:345413</guid><dc:creator>adarshk</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/345413.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=345413</wfw:commentRss><description>&lt;p&gt;If you are looking for some information on understanding the basics of HttpWebRequest connection management and servicepointmanager, I just posted an&amp;nbsp;article which could&amp;nbsp;be useful for you.&lt;/p&gt; &lt;p&gt;&lt;A href="http://blogs.msdn.com/adarshk/articles/345411.aspx"&gt;http://blogs.msdn.com/adarshk/articles/345411.aspx&lt;/a&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in auto"&gt;This is first in the series, in future posting I promise to provide more details about specific scenarios which include Http with&amp;nbsp;authentication and&amp;nbsp;proxy server and also for other protocols like FtpWebRequest and SmtpClient, which were added in .net frameworks 2.0.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=345413" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/HttpWebRequest/default.aspx">HttpWebRequest</category></item><item><title>Update Windows Form UI with Network Available Change Event</title><link>http://blogs.msdn.com/adarshk/archive/2004/12/16/323162.aspx</link><pubDate>Fri, 17 Dec 2004 03:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:323162</guid><dc:creator>adarshk</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/323162.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=323162</wfw:commentRss><description>&lt;p&gt;.Net frameworks 2.0 has a new namespace System.Net.NetworkInformation, which you could use to gather various network statistics on the machine, it also provide two interesting events NetworkAddressChanged and NetworkAvailabilityChanged. If you are writing winform application and want to update some UI information based on network availability status, then Network availibility changed event is very handy for you. Look at following few lines of handy code as demo to change a text label in windows form.&lt;/p&gt; &lt;p&gt;&lt;font color="#000000"&gt;First Step is to hook up an event handler on NetworkChange.NetworkAvailabilityChanged event&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font color="#808080"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public myMainForm()&lt;br /&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;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font color="#808080"&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;&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;&amp;nbsp; Do all your applicatio stuff here&lt;/font&gt;&lt;font color="#808080"&gt;&lt;br /&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateNetworkStatus(NetworkInterface.GetIsNetworkAvailable());&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;br /&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NetworkChange.NetworkAvailabilityChanged +=&lt;/font&gt;&lt;br /&gt;&lt;font color="#808080"&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;&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;new NetworkAvailabilityChangedEventHandler (&lt;/font&gt;&lt;font color="#808080"&gt;myNetworkAvailabilityChangeHandler);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;/p&gt;&lt;/font&gt; &lt;p&gt;&lt;font color="#000000"&gt;Implement the event handler&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font color="#808080" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public void myNetworkAvailabilityChangeHandler(object sender,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NetworkAvailabilityEventArgs args)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {// you can't update UI here because&amp;nbsp;because windows form UI could be only updated on main UI thread&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.Invoke(new WaitCallback(updateNetworkStatus), args.IsAvailable);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font color="#000000"&gt;Implement the method to update the UI information, in this example a label on form will be updated to show the availability of network, but you can do more cool stuff here&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#808080" size="2"&gt;private void updateNetworkStatus(object state)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((bool)state)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&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; lblNetworkStatus.ForeColor = Color.Green;&lt;br /&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; lblNetworkStatus.Text = "NetworkStatus: Online";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&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; lblNetworkStatus.ForeColor = Color.Red;&lt;br /&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; lblNetworkStatus.Text = "NetworkStatus: Offline";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font color="#808080" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;&lt;/p&gt; &lt;p&gt;NetworkAvailability changed is available in post Beta1 bits, check &lt;a href="http://lab.msdn.microsoft.com/vs2005/"&gt;http://lab.msdn.microsoft.com/vs2005/&lt;/a&gt;&amp;nbsp;for latest bits.&lt;/p&gt; &lt;p&gt;&lt;font color="#808080" size="2"&gt;&lt;span style="COLOR: #333333; FONT-FAMILY: 'Trebuchet MS'"&gt;&lt;em&gt;&lt;font size="2"&gt;This posting is provided "AS IS" with no warranties, and confers no rights&lt;/font&gt;&lt;/em&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=323162" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/.Net+Frameworks+2.0/default.aspx">.Net Frameworks 2.0</category></item><item><title>Does your application require customizing System.Net.WebPermission, SocketPermission or DnsPermission settings?</title><link>http://blogs.msdn.com/adarshk/archive/2004/12/06/275522.aspx</link><pubDate>Mon, 06 Dec 2004 09:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:275522</guid><dc:creator>adarshk</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/275522.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=275522</wfw:commentRss><description>&lt;p&gt;.Net frameworks comes with deefault security settings where components running under Intranet, Internet Zone can only have WebPermission to connect back to the&amp;nbsp;server, from where they are downloaded. Also the component from Intranet zone and Internet zone don't have any SocketPermission and DnsPermission by default.&lt;/p&gt; &lt;p&gt;I am trying to find out some real world usage scenarios, where people are customizing these security settings for there application or components in either intranet or internet zone deployment. Special interest is WebPermission, SocketPermission,&amp;nbsp;DnsPermission or NetworkInformationPermission (NetowrkInformationPermission is only in .net frameworks 2.0). &lt;/p&gt; &lt;p&gt;If you are one of them, please drop your comment about scenario and your experience with it.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=275522" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/Software+Testing/default.aspx">Software Testing</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/.Net+Frameworks+2.0/default.aspx">.Net Frameworks 2.0</category></item><item><title>Resuming broken file download with FtpWebRequest class</title><link>http://blogs.msdn.com/adarshk/archive/2004/12/01/273362.aspx</link><pubDate>Wed, 01 Dec 2004 23:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:273362</guid><dc:creator>adarshk</dc:creator><slash:comments>17</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/273362.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=273362</wfw:commentRss><description>&lt;p&gt;This post is valid for .Netframeworks 2.0&lt;/p&gt; &lt;p&gt;When we are downloading a large&amp;nbsp;file from ftp site and connection got broken in between, on next attempt you would be interested in downloading the rest of the file content instead of full file. FtpWebRequest class have a nice way to meet this requirement. You could use the FtpWebRequest.ContentOffset property to specify the starting position for file to download. See code example below&lt;/p&gt; &lt;p&gt;Following is the code for downloading the file&lt;/p&gt; &lt;p&gt;&lt;font color="#808080" size="2"&gt;public static void ResumeFtpFileDownload(Uri sourceUri, string destinationFile)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FileInfo file = new FileInfo(destinationFile);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FileStream localfileStream ;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FtpWebRequest request = WebRequest.Create(sourceUri) as FtpWebRequest;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;request.Method = WebRequestMethods.Ftp.DownloadFile;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (file.Exists)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&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;request.ContentOffset = file.Length;&lt;br /&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;localfileStream = new FileStream(destinationFile, FileMode.Append, FileAccess.Write);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&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;localfileStream = new FileStream(destinationFile, FileMode.Create, FileAccess.Write);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WebResponse response = request.GetResponse();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Stream responseStream = response.GetResponseStream();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;byte[] buffer = new byte[1024];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int bytesRead = responseStream.Read(buffer, 0, 1024);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;while (bytesRead != 0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&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;localfileStream.Write(buffer, 0, bytesRead);&lt;br /&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;bytesRead = responseStream.Read(buffer, 0, 1024);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;localfileStream.Close();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;responseStream .Close();&lt;br /&gt;&amp;nbsp;}&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font color="#808080" size="2"&gt;&lt;span style="COLOR: #333333; FONT-FAMILY: 'Trebuchet MS'"&gt;&lt;em&gt;&lt;font size="2"&gt;This posting is provided "AS IS" with no warranties, and confers no rights&lt;/font&gt;&lt;/em&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=273362" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/.Net+Frameworks+2.0/default.aspx">.Net Frameworks 2.0</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/FtpWebRequest/default.aspx">FtpWebRequest</category></item><item><title>Create your own asp.net hosting server with System.Net.HttpListener</title><link>http://blogs.msdn.com/adarshk/archive/2004/11/21/267721.aspx</link><pubDate>Mon, 22 Nov 2004 02:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:267721</guid><dc:creator>adarshk</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/267721.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=267721</wfw:commentRss><description>&lt;p&gt;.Net frameworks 2.0 contain HttpListener class under System.Net namespace and a number of ASP.Net hosting classes under System.Web.Hosting namespace. &lt;/p&gt; &lt;p&gt;HttpListener class is implemented on top of low level protocol stack&amp;nbsp;http.sys, probably you also know that IIS 6.0 is also architected on top of http.sys. So user of HttpListener class could get advantage of many&amp;nbsp;of the http.sys. System.Web.Hosting namespace is providing the classes to create and handle the ASP.Net hosting envoronment. In combination of both these features you could create your own hosting environment to handle aspx, asmx pages without using the IIS. &lt;/p&gt; &lt;p&gt;I was initially planning to put&amp;nbsp;here some real code sample for simple host application. But looking at recent MSDN magazine, I found Aaron&amp;nbsp;Skonnard has already done a great job in the article &lt;a href="http://msdn.microsoft.com/netframework/default.aspx?pull=/msdnmag/issues/04/12/servicestation/default.aspx"&gt;&lt;strong&gt;Run ASMX Without IIS&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;with complete source code. So for code samples and more details I would recommend to read this MSDN article.&lt;/p&gt; &lt;p&gt;&lt;span style="COLOR: #333333; FONT-FAMILY: 'Trebuchet MS'"&gt;&lt;em&gt;&lt;font size="2"&gt;This posting is provided "AS IS" with no warranties, and confers no rights&lt;/font&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=267721" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/.Net+Frameworks+2.0/default.aspx">.Net Frameworks 2.0</category></item><item><title>HttpWebRequest.GetResponse() gives "HTTP protocol violation" error after .net frameworks service packs</title><link>http://blogs.msdn.com/adarshk/archive/2004/11/08/254090.aspx</link><pubDate>Mon, 08 Nov 2004 20:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:254090</guid><dc:creator>adarshk</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/254090.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=254090</wfw:commentRss><description>&lt;p&gt;This blog is valid for users of .Net frameworks 1.0 SP3 and .Net frameworks 1.1 SP1&lt;/p&gt; &lt;p&gt;The error is really because server is sending response with bad header format, which violates the http protocol specifications. These changes had been made to disallow bad headers.&amp;nbsp;Bad http header could cause&amp;nbsp;security vulnerability based on&amp;nbsp;response-splitting and other attacks based on misinterpreting HTTP streams.&amp;nbsp;&lt;/p&gt; &lt;p&gt;However if your application still need to deal with such responses, you could roll back to old bahavior of relaxed header parsing. You need to use following app.config file.&lt;/p&gt; &lt;p&gt;&lt;font size="2"&gt;&lt;font color="#000080"&gt;&lt;font face="Arial" color="#808080" size="3"&gt;&amp;lt;configuration&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;system.net&amp;gt;&lt;br /&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;lt;settings&amp;gt;&lt;br /&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;httpWebRequest &lt;span class="hl"&gt;useUnsafeHeaderParsing&lt;/span&gt;="true"/&amp;gt;&lt;br /&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;lt;/settings&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/system.net&amp;gt;&lt;br /&gt;&amp;lt;/configuration&amp;gt;&lt;/font&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;font size="2"&gt;&lt;font color="#000080"&gt; &lt;p&gt;&lt;span style="COLOR: #333333; FONT-FAMILY: 'Trebuchet MS'"&gt;&lt;em&gt;&lt;font size="2"&gt;This posting is provided "AS IS" with no warranties, and confers no rights&lt;/font&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=254090" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/HttpWebRequest/default.aspx">HttpWebRequest</category></item></channel></rss>