Home   |   QuickStart Welcome   |   ASP.NET   |   Web Services   |   How Do I...?   
  |   I want my samples in...      

How Do I...? Common Tasks QuickStart Tutorial

How Do I...Make a GET request with SSL?

This sample illustrates how to use the WebRequest and WebResponse classes to make a GET request on a URI with SSL.

There is no actual code difference between this example and the clientGET example. Basically, you can enter a URL with a https:// instead of http:// and the WebRequest will work exactly the same.

The function GetPage is where the specific details of making the request can be found. The rest of the code in this sample is for taking command-line parameters as well as displaying help usage for the parameters. This sample program is a command-line utility that runs at the command prompt.

The GetPage function takes a string parameter, which is the URL (or URI) of the web page to request. This URI is then included as a parameter in a call to WebRequest.Create which creates a WebRequest object.

The GetResponse function of the WebRequest object is then used to get a WebResponse object. This object can be used to get the status code of the response, as well as the actual response stream (a web page, for instance).

Writing out the stream can take several different forms. This example uses a StreamReader instance to read 256 characters into a character array. It then creates a String from the character array and writes out the String using Console.WriteLine.


VB ClientGETwithSSL.exe
View Source
[This sample can be found at C:\DevFusion.Data\legacy\quickstart.developerfusion.co.uk\QuickStart\howto\samples\net\WebRequests\]

Microsoft .NET Framework SDK QuickStart Tutorials Version 2.0
Copyright � 2004 Microsoft Corporation. All rights reserved.