是这样,本来在页面里是通过按钮提交表单,表单有一个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的值添加到请求中呢?

解决方案 »

  1.   

    用+连接~~?
    楼上的,不好意思,我不明白
    ,提交表单,表单数据是放入HTTP请求的主体中,通过webrequest如何实现呢
      

  2.   

    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";

    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();
      

  3.   

    我刚刚看了一下quickstart,跟楼上的差不多,可是好像会调用该方法HttpUtility.UrlEncode进行一下编码,什么时候有必要调用这个方法呢