home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / QuickStart / howto / doc / WebRequests / clientGETwithSSL.aspx < prev    next >
Encoding:
Text File  |  2000-06-11  |  2.4 KB  |  55 lines

  1. <%@ Register TagPrefix="Acme" TagName="SourceRef" Src="/quickstart/util/SrcRef.aspx"%>
  2.  
  3. <!-- #include virtual="/quickstart/howto/include/header.inc" -->
  4.  
  5. <script language="C#" runat="server">
  6.  
  7.     public void Page_Load(Object sender, EventArgs E) 
  8.     {
  9.         // shell the explorer to a directory
  10.         Ref.RunSample = Server.MapPath("/quickstart/howto/samples/net/WebRequests");
  11.  
  12.         Ref.ViewSource = "/quickstart/howto/samples/net/WebRequests/clientGETwithSSL.src";
  13.         Ref.Icon = "/quickstart/images/genicon.gif";
  14.         Ref.Caption = "ClientGETwithSSL.exe";
  15.     }
  16.  
  17. </script>
  18.  
  19. <h4>How Do I...Make a GET request with SSL?</h4>
  20.  
  21. <div class="indent" style="width:660">
  22. <P>
  23. This sample illustrates using the WebRequest and WebResponse classes to make a GET request on a URI with SSL.
  24. </P>
  25. <P>
  26. There is no actual code difference between this example, and the clientGET.cs example. The point is: you can enter a URL with a http<B>s</B>:// instead of http:// and the WebRequest will work exactly the same!
  27. </P>
  28. <P>
  29. 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, and displaying help usage for the parameters as well. This sample program is a command-line utility that runs at the command prompt.
  30. </P>
  31. <P>
  32. The <B>getPage</B> 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 <B>WebRequestFactory.Create</B> which creates a <B>WebRequest</B> object.
  33. </P>
  34. <P>
  35. The <B>GetResponse</B> function of the WebRequest object is then used to get a <B>WebResponse</B> object. This object can be used to get the status code of the response, as well as the actual response stream, for instance a web page. 
  36. </p>
  37. <P>
  38. Actually writing out the stream can take several different forms. This example reads a byte array (of 512 bytes) into the Byte[] variable <B>read</B> with the <B>Read</B> function. It then writes out the 512 bytes with a Console.WriteLine function: Console.Write(System.Text.Encoding.ASCII.GetString(read, 0, bytes));
  39. </P>
  40. </div>
  41.  
  42. <h4>Example</h4>
  43.  
  44. <Acme:SourceRef id="Ref" runat="server" />
  45.  
  46. <h4>Source Code</h4>
  47.  
  48. <div class="code">
  49. <xmp>
  50. <!-- #include virtual="/quickstart/howto/samples/net/WebRequests/clientGETwithSSL.cs" -->
  51. </xmp>
  52. </div>
  53.  
  54. <!-- #include virtual="/quickstart/howto/include/footer.inc" -->
  55.