system.net

Is there a way I can tell whether an SMTP server is expecting a client to connect using “implicit” SSL versus “explicit” SSL?

本小妞迷上赌 提交于 2019-12-02 21:28:19
SSL can either be "explicit" or "implicit" as explained by this link: http://help.globalscape.com/help/secureserver2/Explicit_versus_implicit_SS.htm System.Net.Mail only support "explicit" SSL, as explained here: http://blogs.msdn.com/webdav_101/archive/2008/06/02/system-net-mail-with-ssl-to-authenticate-against-port-465.aspx So, I'm trying to use System.Net.Mail to connect to an SMTP server that I don't have any control over, and it's failing. How can I know for sure that it's failing because the server wants an "implicit" SSL connection? What test can I do from the client side? Ordinarily

Is WebClient really unavailable to .NET 3.5 CF?

早过忘川 提交于 2019-12-02 17:54:14
问题 My app targets Windows CE; it uses the Compact Framework I copied over some elsewhere-working code that uses WebClient, but it won't compile, saying, " The type or namespace name 'WebClient' could not be found (are you missing a using directive or an assembly reference?) " I do have a "using System.Net;" Because of that error, I also get, " The name 'HttpRequestHeader' does not exist in the current context " The code is: private static void SendXMLFile(string xmlFilepath, string uri) { using

Is WebClient really unavailable to .NET 3.5 CF?

廉价感情. 提交于 2019-12-02 08:58:47
My app targets Windows CE; it uses the Compact Framework I copied over some elsewhere-working code that uses WebClient, but it won't compile, saying, " The type or namespace name 'WebClient' could not be found (are you missing a using directive or an assembly reference?) " I do have a "using System.Net;" Because of that error, I also get, " The name 'HttpRequestHeader' does not exist in the current context " The code is: private static void SendXMLFile(string xmlFilepath, string uri) { using (var client = new WebClient()) { client.Headers[HttpRequestHeader.ContentType] = "application/x-www

How to get the IP address in C#?

我们两清 提交于 2019-11-30 22:33:53
Assume that a computer is connected to many networks (actually more than one). I can get a list of IP addresses which includes all IP addresses the computer have in networks, but how can I know that an IP address belongs to which network? sisve First, there are some terms you need to know. These example numbers presume an IPv4 network. IP address (192.168.1.1) subnet mask (255.255.255.0) network address (192.168.1.0) network interface card, NIC (one hardware card may have several of these) To see which network an IP address belongs to requires you to calculate the network address. This is easy

How can I rate limit an upload using TcpClient?

落爺英雄遲暮 提交于 2019-11-30 18:24:58
问题 I'm writing a utility that will be uploading a bunch of files, and would like to provide the option to rate limit uploads. What is the best approach for rate limiting uploads when using the TcpClient class? My first instinct is to call NetworkStream.Write() with a limited number of bytes at a time, sleeping between calls (and skipping a call if the stream isn't done writing yet) until the buffer is uploaded. Has anyone implemented something like this before? 回答1: Implementing speed limit is

How to get the IP address in C#?

谁说我不能喝 提交于 2019-11-30 18:17:08
问题 Assume that a computer is connected to many networks (actually more than one). I can get a list of IP addresses which includes all IP addresses the computer have in networks, but how can I know that an IP address belongs to which network? 回答1: First, there are some terms you need to know. These example numbers presume an IPv4 network. IP address (192.168.1.1) subnet mask (255.255.255.0) network address (192.168.1.0) network interface card, NIC (one hardware card may have several of these) To

How to request only the HTTP header with C#?

点点圈 提交于 2019-11-30 08:08:35
I want to check if the URL of a large file exists. I'm using the code below but it is too slow: public static bool TryGet(string url) { try { GetHttpResponseHeaders(url); return true; } catch (WebException) { } return false; } public static Dictionary<string, string> GetHttpResponseHeaders(string url) { Dictionary<string, string> headers = new Dictionary<string, string>(); WebRequest webRequest = HttpWebRequest.Create(url); using (WebResponse webResponse = webRequest.GetResponse()) { foreach (string header in webResponse.Headers) { headers.Add(header, webResponse.Headers[header]); } } return

Post multiple files and form values using .NET (console application)

家住魔仙堡 提交于 2019-11-30 07:21:04
I want to POST multiple files and form variables to a CGI script, all in one HTTP request. I believe this requires a HTTP post with multipart/form-data encoding. Here is a sample HTML form that sends the required information; I need to send the same information through the application: <form action="/process.php" enctype="multipart/form-data" method="post"> <input type="text" name="foo" value="bar"> <input type="text" name="blah" value="baz"> <input type="file" name="file1"> <input type="file" name="file2"> <input type="file" name="file3"> </form> Please note that the application is a C# .NET

Get IE's default proxy with DefaultWebProxy

佐手、 提交于 2019-11-29 11:38:29
I've read through pretty much all the documentation I can find but I'm yet to find a simple working example of how to get IE's default proxy settings using DefaultWebProxy() . This code seems to compile and work but how do I then go ahead and get the proxy URI as a string? HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create("http://www.google.com"); if (WebRequest.DefaultWebProxy != null) { webRequest.Proxy = WebRequest.DefaultWebProxy; } EDIT: Since submitting this question I have found that one or many proxies can be set for different destinations or bypassed (perhaps for local

How to request only the HTTP header with C#?

谁都会走 提交于 2019-11-29 10:47:38
问题 I want to check if the URL of a large file exists. I'm using the code below but it is too slow: public static bool TryGet(string url) { try { GetHttpResponseHeaders(url); return true; } catch (WebException) { } return false; } public static Dictionary<string, string> GetHttpResponseHeaders(string url) { Dictionary<string, string> headers = new Dictionary<string, string>(); WebRequest webRequest = HttpWebRequest.Create(url); using (WebResponse webResponse = webRequest.GetResponse()) { foreach