winfrom POST代码
url=http://192.168.1.101:8089/Handle/B.ashx
pdata="a=ert45/sd2=&babc=/&c=123=/"
public static string PostHttpHandle(string url, string pdata)
{
Dictionary<string, string> dd = new Dictionary<string, string>();
dd.Add(url, pdata);
string udata = string.Empty;
foreach (KeyValuePair<string, string> kvp in dd)
{
System.Net.HttpWebRequest request2;
request2 = (System.Net.HttpWebRequest)WebRequest.Create(kvp.Key);
request2.Method = "POST";
request2.ContentType = "application/x-www-form-urlencoded;";
byte[] payload;
payload = System.Text.Encoding.UTF8.GetBytes(kvp.Value);
request2.ContentLength = payload.Length;
Stream writer = request2.GetRequestStream();
writer.Write(payload, 0, payload.Length);
writer.Close();
System.Net.HttpWebResponse response;
response = (System.Net.HttpWebResponse)request2.GetResponse();
System.IO.Stream s;
s = response.GetResponseStream();
StreamReader reader = new StreamReader(s);
udata = reader.ReadToEnd();
reader.Close();
}
return HttpUtility.UrlEncode(udata, System.Text.Encoding.UTF8);
}
ashx 接收的代码
//输出会把=号变成%3D /变成%3f
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string token = string.Format(HttpUtility.UrlDecode( context.Request.Form["a"]),System.Text.Encoding.UTF8);
string jqm = string.Format(HttpUtility.UrlDecode( context.Request.Form["b"]),System.Text.Encoding.UTF8);
string my = string.Format(HttpUtility.UrlDecode( context.Request.Form["c"]),System.Text.Encoding.UTF8);
context.Response.Write(my)
}
我想我发送过去的= 和 / 符号 服务器端接收就是=号和/符号 不要编码 另外服务端返回的 = 和 / 符号 我能也能接收到 向服务器POST加密的数据就一定会用到=和/ 这些特殊符号