string keywords = TextBox1.Text;
keywords = keywords.Insert(1," ");
string carstyle = "";
if (DropDownList1.SelectedItem.Text == "小型汽车(蓝牌)")
carstyle = "02";
else if (DropDownList1.SelectedItem.Text == "大型汽车(黄牌)")
carstyle = "01";
Encoding encoding = Encoding.GetEncoding("gb2312");
string postData = "keywords= " + keywords;
string strUrl = "http://weizhang.jmjgj.gov.cn/searchnumber.asp";
postData = postData + ( "&carstyle= " + carstyle);
byte[] data = encoding.GetBytes(postData);
//Response.Write(postData);
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(strUrl);
myRequest.Method = "POST";
myRequest.ContentType= "application/x-www-form-urlencoded ";
myRequest.ContentLength = data.Length;
Stream newStream=myRequest.GetRequestStream();
newStream.Write(data,0,data.Length);
newStream.Close();
try
{
HttpWebResponse myResponse=(HttpWebResponse)myRequest.GetResponse();
StreamReader reader = new StreamReader(myResponse.GetResponseStream(),Encoding.Default);
string content = reader.ReadToEnd();
int beginNum = content.IndexOf("<table");
int endNum = content.IndexOf("</table>",beginNum);
int strNum = endNum - beginNum + 1;
string tableString = content.Substring(beginNum,strNum + 7);
Session["HTML"] = tableString;
Response.Redirect("WebForm2.aspx");
}这样提交我们的两个参数是作为URL参数传过去的吗?
我其中一个参数的值中需要有一个空格。 “粤 B12345”这种格式。我用insert方法加入空格以后为什么那边认出来的是
“粤B12345” 要怎么做?
我在ASP直接做表单提交的时候用JAVASCRIPT这样做 document.form1.textbox.value=textbox_value.substring(0,textbox_value.length).replace('\/'," ");
是可以实现的。
如果用HTTPWEBREQUEST传过去是作为URL参数的话我是不是应该把那个空格写成%20??
keywords = keywords.Insert(1," ");
string carstyle = "";
if (DropDownList1.SelectedItem.Text == "小型汽车(蓝牌)")
carstyle = "02";
else if (DropDownList1.SelectedItem.Text == "大型汽车(黄牌)")
carstyle = "01";
Encoding encoding = Encoding.GetEncoding("gb2312");
string postData = "keywords= " + keywords;
string strUrl = "http://weizhang.jmjgj.gov.cn/searchnumber.asp";
postData = postData + ( "&carstyle= " + carstyle);
byte[] data = encoding.GetBytes(postData);
//Response.Write(postData);
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(strUrl);
myRequest.Method = "POST";
myRequest.ContentType= "application/x-www-form-urlencoded ";
myRequest.ContentLength = data.Length;
Stream newStream=myRequest.GetRequestStream();
newStream.Write(data,0,data.Length);
newStream.Close();
try
{
HttpWebResponse myResponse=(HttpWebResponse)myRequest.GetResponse();
StreamReader reader = new StreamReader(myResponse.GetResponseStream(),Encoding.Default);
string content = reader.ReadToEnd();
int beginNum = content.IndexOf("<table");
int endNum = content.IndexOf("</table>",beginNum);
int strNum = endNum - beginNum + 1;
string tableString = content.Substring(beginNum,strNum + 7);
Session["HTML"] = tableString;
Response.Redirect("WebForm2.aspx");
}这样提交我们的两个参数是作为URL参数传过去的吗?
我其中一个参数的值中需要有一个空格。 “粤 B12345”这种格式。我用insert方法加入空格以后为什么那边认出来的是
“粤B12345” 要怎么做?
我在ASP直接做表单提交的时候用JAVASCRIPT这样做 document.form1.textbox.value=textbox_value.substring(0,textbox_value.length).replace('\/'," ");
是可以实现的。
如果用HTTPWEBREQUEST传过去是作为URL参数的话我是不是应该把那个空格写成%20??
解决方案 »
- 请教购物车的具体操作
- 帮帮忙吧!!!DetailsView的模板列里放置Lable的赋值并显示的问题
- 关于ASP.NET网站报错的一个很诡异,很纠结,很痛苦的问题。帮顶者也有分~~!
- 对 XML操作~~帮我出出注意啊~~大家一起参考~
- datalist中有两个服务器端控件Label和一个客户端控件checkbox点击checkbox怎么得到label的值呀
- Application的问题..50分
- 初学者有关数据绑定的求救,急! (毕业设计)
- 在项目上操作一会后,页面所有按钮和链接都没有反应了
- 求datagrid的update,cancel,delet的vb的coid behind的代码(简单的初学)
- 怎么通过改变DropDownList或ListBox来触发事件阿?急!急!急!
- 怎么设置menu控件的子菜单的对齐方式 ?
- [ASP.NET]Windows身份认证下如何做重新登陆的操作
不过lz建议你还是对Url进行编码以后再传输,不仅仅是空格的问题,很多的特殊符号包括中文字都会在url传输的过程中丢失的,所以编码是较为安全的一种做法!
这不是POST方法吗?为什么参数还是按照URL提交的呢?