Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are missing a constructor for your Connector class which needs to initialize your CookieContainer property. You should also use a CookieCollection for capturing the cookies from the response and sending to the next request. Something like this should work:</p> <pre><code>public class Connector { public CookieContainer session_cookie; private CookieCollection cookies; private string session_id; private HttpWebRequest HTTPReq; private HttpWebResponse Response; public Connector() { session_cookie = new CookieContainer(); cookies = new CookieCollection(); } //Session oriented connection public string serverRequest(string scriptURL, string payLoad) { try { HTTPReq = (HttpWebRequest)WebRequest.Create(scriptURL); HTTPReq.CookieContainer = session_cookie; HTTPReq.CookieContainer.Add(cookies); HTTPReq.Method = "POST"; //Data arguments byte[] byteArray = Encoding.UTF8.GetBytes(payLoad); HTTPReq.ContentType = "application/x-www-form-urlencoded"; HTTPReq.ContentLength = byteArray.Length; //Get the stream to write into Stream dataStream = HTTPReq.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); Response = (HttpWebResponse)HTTPReq.GetResponse(); cookies = Response.Cookies; // capture cookies from response for next request Encoding enc = Encoding.GetEncoding(1252); // Western latin alphabet (windows default) //Get the repsonse from the server StreamReader ResponseStream = new StreamReader(Response.GetResponseStream(), enc); string response = ResponseStream.ReadToEnd().Trim(); Response.Close(); ResponseStream.Close(); return response; } catch (WebException ex) { Console.WriteLine(ex.ToString()); return null; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload