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

  1.  
  2. <!-- #include virtual="/quickstart/howto/include/header.inc" -->
  3.  
  4. <%
  5.     runsample = Server.MapPath("/quickstart/howto/samples/net/WebRequests")
  6.     viewsource = "/quickstart/howto/samples/net/WebRequests/clientGET.src"
  7.     icon = "/quickstart/images/genicon.gif"
  8.     caption = "ClientGET.exe"
  9. %>
  10.  
  11. </script>
  12.  
  13. <h4>How Do I...Make a GET request?</h4>
  14.  
  15. <div class="indent" style="width:660">
  16. This sample illustrates using the WebRequest and WebResponse classes to make a GET request on a URI.
  17. <BR>
  18. <P>
  19. The function getPage is where the specific details of making the request can be found. The rest 
  20. of the code in this sample is for taking command-line parameters, and displaying help usage for 
  21. the parameters as well. This sample program is a command-line utility that runs at the command prompt.
  22. </p>
  23. <P>
  24. The <B>getPage</B> function takes a string parameter, which is the URL (or URI) of the web page to 
  25. request. This URI is then included as a parameter in a call to <B>WebRequestFactory.Create</B> which 
  26. creates a <B>WebRequest</B> object.
  27. </P>
  28. <P>
  29. The <B>GetResponse</B> function of the WebRequest object is then used to get a <B>WebResponse</B> 
  30. object. This object can be used to get the status code of the response, as well as the actual response 
  31. stream, for instance a web page. 
  32. </P>
  33. <P>
  34. Actually writing out the stream can take several different forms. This example reads a byte array 
  35. (of 512 bytes) into the Byte[] variable <B>read</B> with the <B>Read</B> function. It then writes 
  36. out the 512 bytes with a Console.WriteLine function: Console.Write(System.Text.Encoding.ASCII.GetString(read, 0, bytes));
  37. </p>
  38. </div>
  39.  
  40. <h4>Example</h4>
  41.  
  42. <p>
  43. <div class="indent">
  44. <a target="_blank" href="<%=runsample%>">
  45. <img style="border-color:black" border=1 src="<%=icon%>"><br>
  46. </a>
  47. <div class="caption"><%=caption%></div><br>
  48. [<a target="_blank" href="<%=runsample%>">View Sample</a>] | 
  49. [<a target="_blank" href="/quickstart/util/srcview.aspx?path=<%=viewsource%>">View Source</a>]<p>
  50. </div>
  51.  
  52. <h4>Source Code</h4>
  53.  
  54. <div class="code">
  55. <xmp>
  56. <!-- #include virtual="/quickstart/howto/samples/net/WebRequests/clientGET.cs" -->
  57. </xmp>
  58. </div>
  59.  
  60. <!-- #include virtual="/quickstart/howto/include/footer.inc" -->
  61.