home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / QuickStart / howto / doc / WebRequests / clientPOST.aspx < prev   
Encoding:
Text File  |  2000-06-11  |  1.7 KB  |  52 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.         // run an aspx page directly
  13.         // Ref.RunSample = "/quickstart/howto/samples/BaseDataTypes/Sort/Sort.aspx";
  14.  
  15.         Ref.ViewSource = "/quickstart/howto/samples/net/WebRequests/clientPOST.src";
  16.         Ref.Icon = "/quickstart/images/genicon.gif";
  17.         Ref.Caption = "ClientPOST.exe";
  18.     }
  19.  
  20. </script>
  21.  
  22. <h4>How Do I...Make a POST request?</h4>
  23.  
  24. <div class="indent" style="width:660">
  25. <P>
  26. This sample illustrates using the WebRequest and WebResponse classes to make a POST request on a URI.</div>
  27. </P>
  28. <P>
  29. This sample is similar to a simple WebRequest with a GET verb. The difference here is twofold: 1) The verb needs to be changed to be
  30. POST, 2) the form information needs to be encoded and sent up the stream.
  31. </P>
  32. <P>
  33. To change the verb, simple set the <B>Method</B> property to "POST".
  34. </p><P>
  35. You must then set the <B>ContentType</B> property to "application/x-www-form-urlencoded". At this point, make sure that the string
  36. you supply is encoded correctly, and everything will be POSTed correctly.
  37. </P>
  38.  
  39. <h4>Example</h4>
  40.  
  41. <Acme:SourceRef id="Ref" runat="server" />
  42.  
  43. <h4>Source Code</h4>
  44.  
  45. <div class="code">
  46. <xmp>
  47. <!-- #include virtual="/quickstart/howto/samples/net/WebRequests/clientPOST.cs" -->
  48. </xmp>
  49. </div>
  50.  
  51. <!-- #include virtual="/quickstart/howto/include/footer.inc" -->
  52.