Httpsenddata. aspx
<% @ Page Language = "C #" %>
<% @ Import namespace = "system" %>
<% @ Import namespace = "system. Collections" %>
<% @ Import namespace = "system. Web" %>
<% @ Import namespace = "system. Web. UI" %>
<% @ Import namespace = "system. Web. UI. webcontrols" %>
<% @ Import namespace = "system. Net" %>
<% @ Import namespace = "system. Io" %>
<% @ Import namespace = "system. Text" %>
<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">
<HTML>
<Head>
<SCRIPT runat = "server">
Void button#click (Object sender, system. eventargs E)
{
String strtitle = textbox1.text;
String strdesc = textbox2.text;
Encoding encoding = encoding. getencoding ("gb2312 ");
String postdata = "Title =" + strtitle;
String strurl = "http://xml.sz.luohuedu.net/HttpReceiveData.aspx ";
Postdata + = ("& DESC =" + strdesc );
Byte [] DATA = encoding. getbytes (postdata );
// Prepare the request...
Httpwebrequest myrequest = (httpwebrequest) webrequest. Create (strurl );
Myrequest. method = "Post ";
Myrequest. contenttype = "application/X-WWW-form-urlencoded ";
Myrequest. contentlength = data. length;
Stream newstream = myrequest. getrequeststream ();
// Send data
Newstream. Write (data, 0, Data. Length );
Newstream. Close ();
Response. Redirect ("httpsenddata. aspx ");
}
</SCRIPT>
</Head>
<Body>
<Form ID = "httppost" method = "Post" runat = "server">
Title: <asp: textbox id = "textbox1" runat = "server"> </ASP: textbox>
<Br>
Content:
<Br>
<Asp: textbox id = "textbox2" runat = "server" textmode = "multiline" rows = "10" columns = "100"> </ASP: textbox>
<Br>
<Asp: button id = "button1" runat = "server" text = "sending" onclick = "button#click"> </ASP: button>
</Form>
</Body>
</Html>
Httpreceivedata. aspx
<% @ Page Language = "VB" %>
<% @ Import namespace = "system" %>
<% @ Import namespace = "system. Web. UI" %>
<% @ Import namespace = "system. Web" %>
<SCRIPT runat = "server">
Sub page_load (byval sender as system. Object, byval e as system. eventargs)
If request. servervariables ("request_method"). tostring () = "Post" then
Dim connstr as string
Connstr = "provider = Microsoft. Jet. oledb.4.0; Data Source =" + server. mappath ("test. mdb ")
Dim cn as new system. Data. oledb. oledbconnection (connstr)
Dim strsql as string = "insert into testtable (title, description) values ('"_
+ Request. Form ("title"). tostring () + "','" + request. Form ("DESC"). tostring () + "')"
CN. open ()
Dim cmd as new system. Data. oledb. oledbcommand (strsql, CN)
Cmd. executenonquery ()
CN. Close ()
CN. Dispose ()
Cmd. Dispose ()
End if
End sub
</SCRIPT>