.NET Framework: Send & Receive Data via HTTP

This solution demonstrates how to send and receive data using HTTP and streams using the System.Net classes.

Highlights

The form contains four Button controls, two TextBox controls, and one PictureBox control. The first three buttons show how to send and receive data from a file. The last button shows how to send text back and forth to the web application. When using the fourth button, the text in the editable text box is sent to the web server, and the returned text is displayed in the read-only text box. Additionally, there is a virtual directory named SendAndReceiveDataWebPages that receives and returns data.

File I/O is performed in and out of the files using FileStreams. Network I/O is performed between client and server using Request and Response streams.

Requirements

Requires the Trial or Release version of Visual Studio .NET Professional (or greater) 2003.
Also requires a version of Windows that supports ASP.NET.

Running the Sample

  1. Run the Setup.vbs file located in the root folder of this sample to create the virtual directory.

    The application communicates with a set of ASP.NET files that are served up by IIS. The Setup.vbs file copies these files from a subdirectory of the sample to a subdirectory of the default Web site.

  2. Complete the following steps to allow the ASPNET account to read and write to the virual folder created by Setup.vbs.
    1. Open Windows Explorer.
    2. Navigate to the physical folder containing the ASPX files. This will typically be under C:\InetPub\wwwroot.
    3. Right-click on the SendAndReceiveDataWebPages folder and select Properties.
    4. Click the tab named Security.
    5. Click the Add button.
    6. Click the Locations button and select the node that represents your computer. Click OK.
    7. In the text box labeled 'Enter the object names to select (examples):' type ASPNET and then click the Check Names button. Click OK once the name validates.
    8. Next select the Modify check box under the Allow column and then click OK.

  3. Press F5 to run the Windows application.