Using system.net; using system.ipe; using system.text;
[Stathread]
Static
Void
Main
String
[] ARGS)
{// // TODO: Add code here to start the application // string url = "http://localhost/9cbs2/1.asp"; // <% // if Request ("aa") = " Zhuye "The session (" ok ") =" ok "// if session (" ok ") =" ok "THEN / / RESPONSE.WRITE (" Login) // Else // Response.write ("No Login" ) // end if //%> string indata = "aa = zhuye"; string outdata = ""; CookieContainer myCookieContainer = new CookieContainer (); // Create a set Cookie CookieContainer to store HttpWebRequest myHttpWebRequest = (HttpWebRequest) WebRequest.Create (url); // Create a HttpWebRequest myHttpWebRequest.ContentType = "application / x-www-form-urlencoded"; myHttpWebRequest.ContentLength = indata.Length; myHttpWebRequest.Method = "POST"; myHttpWebRequest.CookieContainer = myCookieContainer; // set HttpWebRequest's cookiecontainer is the MyCookieContainer that is built. Stream myRequestStream = myHttpWebRequest.GetRequestStream (); StreamWriter myStreamWriter = new StreamWriter (myRequestStream, Encoding.GetEncoding ( "gb2312")); myStreamWriter.Write (indata); // writes data stream of HttpWebRequest Request myStreamWriter.Close (); MyRequestStream.close (); // Close open object httpwebresponse myhttpWebResponse = (httpwebresponse) MyHttpWebRequest.getResponse (); // New an httponse.cookies =
myCookieContainer.GetCookies (myHttpWebRequest.RequestUri); // Get CookieCollection Stream myResponseStream = myHttpWebResponse.GetResponseStream Cookie comprising a set of url (); StreamReader myStreamReader = new StreamReader (myResponseStream, Encoding.GetEncoding ( "gb2312")); outdata = myStreamReader .ReadToend (); // reads data from httpwebresponse's response stream (); myresponsestream.close (); console.writeline (outdata); // Display "Login" // Get cookie, request can be read directly to the registered contents of myHttpWebRequest = (HttpWebRequest) WebRequest.Create (url); myHttpWebRequest.CookieContainer = myCookieContainer; // * // CookieContainer just that there has been a Cookie, attach it to the HttpWebRequest directly through the verification myHttpWebResponse = (HttpWebResponse) myHttpWebRequest.GetResponse (); myHttpWebResponse.Cookies = myCookieContainer.GetCookies (myHttpWebRequest.RequestUri); myResponseStream = myHttpW ebResponse.GetResponseStream (); myStreamReader = new StreamReader (myResponseStream, Encoding.GetEncoding ( "gb2312")); outdata = myStreamReader.ReadToEnd (); myStreamReader.Close (); myResponseStream.Close (); Console.WriteLine (outdata); // Display "Login" again // If the * line note is released, "no login"} STEM.IO;
Using
System.Text;
Using
System;
Using
System.net;
Using
System.IO;
Using
System.Text;
[Stathread]
Static
Void
Main
String
[] ARGS)
{// // TODO: Add code here to start the application // string url = "http://localhost/9cbs2/1.asp"; // <% // if Request ("aa") = " Zhuye "The session (" ok ") =" ok "// if session (" ok ") =" ok "THEN / / RESPONSE.WRITE (" Login) // Else // Response.write ("No Login" ) // end if //%> string indata = "aa = zhuye"; string outdata = ""; CookieContainer myCookieContainer = new CookieContainer (); // Create a set Cookie CookieContainer to store HttpWebRequest myHttpWebRequest = (HttpWebRequest) WebRequest.Create (url); // Create a HttpWebRequest myHttpWebRequest.ContentType = "application / x-www-form-urlencoded"; myHttpWebRequest.ContentLength = indata.Length; myHttpWebRequest.Method = "POST"; myHttpWebRequest.CookieContainer = myCookieContainer; // set HttpWebRequest's cookiecontainer is the MyCookieContainer that is built. Stream myRequestStream = myHttpWebRequest.GetRequestStream (); StreamWriter myStreamWriter = new StreamWriter (myRequestStream, Encoding.GetEncoding ( "gb2312")); myStreamWriter.Write (indata); // writes data stream of HttpWebRequest Request myStreamWriter.Close (); MyRequestStream.close (); // Close open object httpwebresponse myhttpWebResponse = (httpwebresponse) MyHttpWebRequest.getResponse (); // New an httponse.cookies =