问题描述
functionjieguo(fid,bid){if(fid){varurl="../HtmlPage/RoomInfo.aspx?fid="+fid+"&bid="+bid;window.location.href=url;}else{jQuery("#txtCode").val("");jQuery("#Label2").html("验证码输入错误!");}}
如果验证码输入正确,则在后台调用前台的这个jieguo(,)【后台应该是使用RegisterStartupScript("jieguo(a,b),")】函数跳转,现在我在winform代码中模拟请求跳转后的地址,请问怎么获取到这两个参数?还望大神不吝赐教
解决方案
解决方案二:
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Text;usingSystem.Net;usingSystem.IO;namespaceFactoryCollect.common{publicclassHttpHelper{publicstaticstringPost(stringurl,stringcontent,stringencoding){//获取提交的字节,这里的字符编码根据实际情况而定byte[]bs=Encoding.GetEncoding("gb2312").GetBytes(content);//设置提交的相关参数HttpWebRequestreq=(HttpWebRequest)HttpWebRequest.Create(url);req.Method="POST";req.ContentType="application/x-www-form-urlencoded";req.ContentLength=bs.Length;req.KeepAlive=false;//提交请求数据StreamreqStream=req.GetRequestStream();reqStream.Write(bs,0,bs.Length);reqStream.Close();//接收返回的页面,必须的,不能省略WebResponsewr=req.GetResponse();//获取跳转页面的地址,然后再用(HttpWebRequest)HttpWebRequest.Create(url);重新请求url=wr.ResponseUri.AbsoluteUri;req=(HttpWebRequest)HttpWebRequest.Create(url);req.Method="GET";//接收返回的页面,必须的,不能省略wr=req.GetResponse();System.IO.StreamrespStream=wr.GetResponseStream();System.IO.StreamReaderreader=newSystem.IO.StreamReader(respStream,System.Text.Encoding.GetEncoding(encoding));stringt=reader.ReadToEnd();wr.Close();respStream.Close();reader.Close();returnt;}}}