Programming Tutorial On The Way

free online programming resource on dotnet, csharp, web related topics

Downloading Data from a Server

If you want to write some code to download data a location specified by a URI, simply you can use the WebClient DownloadData and DownloadFile methods; this data can be either an array of bytes or a file. WebClient simplifies downloading of files and bytes in files, as these are common tasks when dealing with the Web. The more traditional stream-based method for downloading can also be accessed via the OpenRead method on the WebClient.
Read the rest of this entry »

Popularity: 2% [?]

Writing a TCP Server

You need to create a server that listens on a port for incoming requests from a TCP client. These client requests can then be processed at the server, and any responses can be sent back to the client. Read the rest of this entry »

Popularity: 4% [?]

Writing a TCP Client

You can use the TcpClient class to connect to and converse with a TCP-based server by passing the address and port of the server to talk to, as shown in the snippet code below: Read the rest of this entry »

Popularity: 4% [?]

Obtaining the HTML from a URL

You need to get the HTML returned from a web server in order to examine it for items of interest. For example, you could examine the returned HTML for links to other pages or for headlines from a news site. Read the rest of this entry »

Popularity: 2% [?]

Handling Web Server Errors

You have obtained a response from a web server and you want to make sure that there were no errors in processing the initial request, such as failing to connect, being redirected, timing out, or failing to validate a certificate. You don’t want to have to catch all of the different response codes available. Read the rest of this entry »

Popularity: 2% [?]

Going Through a Proxy

Many companies have a web proxy that allows employees to access the Internet, while at the same time preventing outsiders from accessing the company’s internal network. The problem is that to create an application that accesses the Internet from within your company, you must first connect to your proxy and then send information through it, rather than directly out to an Internet web server. Read the rest of this entry »

Popularity: 3% [?]

You want to send a request to a web server in the form of a GET or POST request. After you send the request to a web server, you want to get the results of that request (the response) from the web server. The WebRequest and WebResponse classes of System.Net namespace encapsulate all of the functionality to perform basic web transactions. HttpWebRequest and HttpWebResponse are derived classes from these, respectively, and provide the HTTP specific web transaction support. Read the rest of this entry »

Popularity: 5% [?]

Forming an Absolute URI

The System.Net.Uri class has a constructor overload that allows you to create a URI from a base path and a relative path while controlling the escaping of the URI. This creates the absolute URI and places it in the Uri.AbsoluteUri property. Escaping/Unescaping can also be controlled through two other overloads of the Uri constructor that take a bool as the last parameter (dontEscape), but care needs to be taken here: if you unescape the Uri, it will put the URI into a form more readable by a human but no longer usable as a URI (this is because any spaces that were escaped as %20 will now be considered whitespace). Read the rest of this entry »

Popularity: 3% [?]

« Previous Entries