All pastes #215769 Raw Edit

wladek2

public text v1 · immutable
#215769 ·published 2006-10-22 20:11 UTC
rendered paste body
            // Header field definitions
            // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
            httpRequest.Open("GET", txtUrl.Text, true, "", "");
            httpRequest.SetRequestHeader("Accept", "text/html");
            // Cache-Control header - "no-cache" - Do not cache the http response
            httpRequest.SetRequestHeader("Cache-Control", "no-cache");

            httpRequest.Send(msg);

///// httpRequest.Open

// lgRequest is a HttpWebRequest object

lgRequest = (HttpWebRequest)WebRequest.CreateDefault(uriObj);
lgRequest.Method = Method; // "GET"

///// httpRequest.SetRequestHeader (just sets my request header attributes of the HttpWebRequest object)

lgRequest.Accept = headerValue; // "text/html"

///// httpRequest.Send

if (lgReadyState != clientState.LOADING)
    throw new InvalidOperationException("Sending a message is not allowed at this ReadyState");

// Assign callback method, this line gives me the exception when using "GET"
IAsyncResult res = lgRequest.BeginGetRequestStream(new AsyncCallback(ReqCallback),lgRequest);
lgReadyState = clientState.LOADED;

///// httpRequest.ReqCallBack

HttpWebRequest req = (HttpWebRequest)ar.AsyncState;
			
// Code below used to write in POST data to connection header, using GET so commented out
//Stream stream = req.EndGetRequestStream(ar);
//StreamWriter streamW = new StreamWriter(stream);
//streamW.Write(lgMsg);
//streamW.Close();
//stream.Close();

IAsyncResult resp = req.BeginGetResponse(new AsyncCallback(RespCallback), req);