All classes in the System.Net namespace have improved stability and performance. Standards compliance has been improved for FTP, HTTP, SMTP, and URIs, with better support for internationalization.
NOTE
At the time of writing, little information is available about these changes, so I apologize for the lack of detail.
Applications running on Vista onward can now handle multiple versions of the IP protocol (v4 and v6) by setting the IPv6Only option to false when creating the socket.
HttpWebRequest has had two new properties added:
Date, for setting the HTTP date header
Host, for setting the HTTP host header (this can be useful for testing load balancing scenarios to test the connection to a particular server)
Examples of these properties are as follows:
string loadbalancerIp = "http://127.0.0.1/"; string host = "mywebsite.com"; var request = WebRequest.Create("http://127.0.0.1/") as HttpWebRequest; request.Date = System.DateTime.Now;
Support has also been added in HttpWebRequest.AddRange() for int64 ranges.
DnsEndPoint is a new class that allows you to create a socket connection by specifying a FQDN name without making a call to Dns.GetHostAddresses(), resulting in reduced and clearer code—for example:
var socket = new System.Net.Sockets.Socket(new System.Net.Sockets.SocketInformation()); socket.Connect(new DnsEndPoint("www.microsoft.com", 80));
For interoperability, it is sometimes necessary to turn off SSL encryption (a null cipher). HttpWebRequest, FtpWebRequest, and SmtpClient now allow you to use a null cipher by specifying it using the System.Net.Security.EncryptionPolicy enum or in Web/machine.config:
The SMTP client contains a number of useful enhancements:
Enabling SSL mode in application config files
Specifying heading encoding
Multiple replying to addresses through MailMessage.ReplyToList()
Many applications are located behind a firewall, which can cause complications when communicating with them. One way around this is network address translation (NAT) transversal, which takes care of various complications. In .NET 4.0, NAT transversal support has been added to TcpListener and UdpClient.
New performance counters have been added for WebRequest:
HttpWebRequests created/sec
HttpWebRequests queued/sec
HttpWebRequests aborted/sec
HttpWebRequests failed/sec
HttpWebRequest average lifetime
HttpWebRequests' average queue time
You can review the diagram shown here to see where they occur in a request lifetime: http://blogs.msdn.com/blogfiles/ncl/WindowsLiveWriter/NewNCLFeaturesin.NET4.0Beta2_78A0/image_2.png.
.NET 4.0 has some new features that are available only for Windows 7 machines.
.NET 4.0 contains a new API for querying Windows 7's location functionality. The Location class supports multiple devices such as GPS and wireless wide area network (WWAN—wireless by cellular phone technology). It returns the current latitude, longitude, altitude, horizontal and vertical accuracy, course, speed, and civic address (country/region, state/province, city, postal code, street, building, and floor level, if available). At the time of writing, the Network Class Library (NCL) team is currently refactoring these libraries.
Windows 7 introduces enhanced security features to prevent replay network attacks. Classes in System.Net and related namespaces such as HttpWebListener, HttpWebRequest, NegotiateStream, SmtpClient, and SSLStream will now utilize these enhancements by default when Windows authentication is used. For the nitty-gritty full details of these changes, consult http://msdn.microsoft.com/en-us/library/dd582691(VS.100).aspx.
3.140.186.206