是这样,本来在页面里是通过按钮提交表单,表单有一个checkbox,它是否选中对得到的页面有影响,提交表单是POST请求,
现在我想通过webrequest来实现
string URL=@"http://www.shelbycountyjail.com/scsoweb/wc.dll?WWSCSOWEB~injail";
WebRequest webRequest=WebRequest.Create(URL);
webRequest.ContentType="application/x-www-form-urlencoded";
webRequest.Method="POST";
WebResponse response=webRequest.GetResponse();
Stream stream=response.GetResponseStream();
如何把checkbox的值添加到请求中呢?
现在我想通过webrequest来实现
string URL=@"http://www.shelbycountyjail.com/scsoweb/wc.dll?WWSCSOWEB~injail";
WebRequest webRequest=WebRequest.Create(URL);
webRequest.ContentType="application/x-www-form-urlencoded";
webRequest.Method="POST";
WebResponse response=webRequest.GetResponse();
Stream stream=response.GetResponseStream();
如何把checkbox的值添加到请求中呢?
楼上的,不好意思,我不明白
,提交表单,表单数据是放入HTTP请求的主体中,通过webrequest如何实现呢
WebRequest webRequest=WebRequest.Create(URL);
webRequest.ContentType="application/x-www-form-urlencoded";
webRequest.Method="POST";
string param="CheckBox1=on"; Byte[] b = System.Text.Encoding.UTF8.GetBytes(param);
webRequest.ContentLength = b.Length;
Stream stream= webRequest.GetRequestStream();
stream.Write(b,0,b.Length);
WebResponse response=webRequest.GetResponse();