(Forum Q & A Drops) If POST information is to a URL, you can pass the cookiecontainer to pass the verification directly.

xiaoxiao2021-03-05  26

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 =

转载请注明原文地址:https://www.9cbs.com/read-33108.html

New Post(0)