62,243
社区成员




var result = new WebClient().UploadData("http://www.abc.com/site1/handler1.ashx?p1="+ p1Str +"&p2=" + p2Str, Encoding.UTF8.GetBytes(jsonStr));
假设使用 jQuery.post 方式,那么也是一样要将 url 参数跟以text 类型 post 的参数分别表示,才能传送到你的程序中。[/quote]
正解var result = new WebClient().UploadData("http://www.abc.com/site1/handler1.ashx?p1="+ p1Str +"&p2=" + p2Str, Encoding.UTF8.GetBytes(jsonStr));
假设使用 jQuery.post 方式,那么也是一样要将 url 参数跟以text 类型 post 的参数分别表示,才能传送到你的程序中。public void ProcessRequest(HttpContext context)
{
var param1 = context.Request.QueryString["p1"];
var param2 = new StreamReader(req.InputStream, Encoding.UTF8).ReadToEnd();
..............
}
这里,读取了get url参数,也都去了 post text 消息体参数。因此“短”的参数和“长”的参数都能读取。 public void ProcessRequest(HttpContext context)
{
var obj = context.Request;
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}
obj就是拿到的请求的东西
private string body
{
get
{
var data = "";
using (var dr = new System.IO.StreamReader(Request.InputStream))
{
data = dr.ReadToEnd();
}
return data;
}
}
就完了吗?
你们说那么多 LZ也不知道怎么回事啊...