system.net

C# Performance For Proxy Server (vs C++)

I want to create a simple http proxy server that does some very basic processing on the http headers (i.e. if header x == y, do z). The server may need to support hundreds of users. I can write the server in C# (pretty easy) or c++ (much harder). However, would a C# version have as good of performance as a C++ version? If not, would ...

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

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...

Ping always succeeds, cant easily check uptime using ping on a url

Im getting frustrated because of OpenDNS and other services (ie: roadrunner) that now always returns a ping even if you type any invalid url ie: lkjsdaflkjdsjf.com --- I had created software for my own use that would ping a url to verify if the site was up or not. This no longer works. Does anyone have any ideas about this? Requiremen...

Is it possible to convert between Socket and TcpClient objects?

Here's another C#/.NET question based merely on curiousity more than an immediate need ... If you had a Socket instance and you wanted to wrap it in the higher-level TcpClient class, is that possible and how would you do it? Conversely if you have an instance of TcpClient, is it possible to get the underlying Socket? ...

System.Net's Webclient in C# won't connect to server.

Is there something I need to do to get System.Net working with Microsoft Visual C# 2008 Express Edition? I can't seem to get any web type controls or classes to work at all.. the below WebClient example always throws the exception "Unable to connect to the remote server".. and consequently I can't get the WebBrowser control to load a pag...

Uri.AbsolutePath messes up path with spaces

In a WinApp I am simply trying to get the absolute path from a Uri object: Uri myUri = new Uri(myPath); //myPath is a string //somewhere else in the code string path = myUri.AbsolutePath; This works fine if no spaces in my original path. If spaces are in there the string gets mangled; for example 'Documents and settings' becomes 'Docu...

C#: access programatically system.net settings from app.config

I am trying to programatically access windows application app.config file. In particular i am trying to access the "system.net/mailSettings" The following code Configuration config = ConfigurationManager.OpenExeConfiguration(configFileName); MailSettingsSectionGroup settings = (MailSettingsSectionGroup)config.GetSectionGroup(@"sy...

Non-Stop Exceptions in C#

I am writing some C# 2.0 code which must do basic HTTP GETs and POSTs. I am using System.Net.HttpWebRequest to send both types of request and System.Net.HttpWebResponse to receive both. My code for GET looks like: HttpWebRequest request = (HttpWebRequest)WebRequest.Create(String.Format("{0}?{1}", URLToHit, queryString)); request...

c# system.net.FileWebRequest Access denied error

I want to get a file size over network via System.Net.FileWebRequest. For example: \IP\c$\sampleFile.txt I supply the credentials for accessing file via passing it to FilewebRequest's credentials but the code below returns an access to path denied error. What is worng here? How can I access files over network? (I have crediantals to ...

System.Net.WebClient fails weirdly

I am trying to download some data from the reporting services instance on our TFS server. Given that the code should run on a computer that is not domain-joined, I figured that I would set the credentials myself. No luck, got a HTTP 401 Unauthorized back. Ok, so I hooked up Fiddler to see what was happening. But that's when I got He...

Update app.config system.net setting at runtime

I need to update a setting in the system.net SectionGroup of a .Net exe app.config file at runtime. I don't have write access to the original config file at runtime (I am developing a .Net dll add-in which is hosted in an exe provided by the app which I have no control over) so I was hoping to save a copy of the file and replace the conf...

How can I rate limit an upload using TcpClient?

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 ...

Send a file via HTTP POST with C#

Hi everyone, I've been searching and reading around to that and couldn't fine anything really useful. I'm writing an small C# win app that allows user to send files to a web server, not by FTP, but by HTTP using POST. Think of it like a web form but running on a windows application. I have my HttpWebRequest object created using somethi...

How to set a Host header value for SSL requests using HttpWebRequest

I am trying to use the System.Net.HttpWebRequest class to perform a HTTP GET request to a specific web server for web applications we have load balanced over numerous servers. In order to achieve this, I need to be able to set the Host header value for the request, and I have been able to achieve this by using the System.Net.WebProxy cla...

Long time to load first connection in C# .NET

I'm making a program that connects to a website and downloads XML from it. It then displays the information to the user. The problem I am having is when I first open the program and start downloading the XML information it takes a really long time. When I load another page from the site with the program still open, it takes about half ...

OPTS command on FtpWebRequest/FtpWebResponse

I'm using the FtpWebRequest and FtpWebResponse objects in the System.Net namespace to issue a LIST command. The problem I'm having is that the FTP server I'm connecting to does not have the OPTS command implemented. Is there a way of preventing FtpWebRequest from issuing the OPTS command? ...

http connection reuse

I would like to better understand how .Net http connection reuse works. When I use HttpWebRequest to send something to some server twice from the same appdomain, is the connection (optionally) reused? So the server would see both requests as coming from the same connection even though in my application they are different logical reques...

HttpWebRequest.Address vs HttpWebResponse.ResponseUri

Whats the difference between these two properties? To put into context, I am determining if a redirect occurs if our ResponseUri != RequestUri. While a redirect occurs regardless the url http://adage.com/adages/article?article%5Fid=140560 will provide a different ResponseUri (http://adage.com/adages/post.php) than the Address (http://a...

getting "remote server cannot be resolved" on localhost does not get fixed by defaultProxy?

here is the sitution, i am testing on my localhost from my machine at home (no proxy server and windows default firewall) and retrieving api.flickr.com xml file, when I come to work (that uses an ISA server to connect) I get "remote server could not be resolved" so I added these lines to the web.config <system.net> <defaultProxy> <...

.NET: WebBrowser, WebClient, WebRequest, HTTPWebRequest... ARGH!

In the System.Net namespace, there are very many different classes with similar names, such as: WebBrowser and WebClient WebRequest and HTTPWebRequest WebResponse and HTTPWebResponse Those are the main ones I'm curious about. What is each one's function? How are they different from one another? Also, in what cases would you use whi...