客户端 用C# 代码:
public static void PostString (string address)
{
   string data = "Time = 12:00am temperature = 50";
   string method = "POST";
   WebClient client = new WebClient ();
   string reply = client.UploadString (address, method, data);   Console.WriteLine (reply);
}问 服务器端(aspx) 如何接收和处理 发送过来的数据?

解决方案 »

  1.   

    [Quote=引用楼主 zhenpei 的回复:]
    我没有用WebForm  直接是ashx
    怎么接收啊
      

  2.   

    还是不行啊兄弟,取不到,count为0
    context.Request.Form.Count
    为什么啊?
      

  3.   

    不好意思,点错了,
    HttpContext.Request.Form 取不到,还有其它方法吗,谢谢
      

  4.   

    搞定了 NameValueCollection data = new NameValueCollection();
    WebClient wb = new WebClient();
    data.Add("key", "Value");
    string temp = Encoding.UTF8.GetString(wb.UploadValues(url, "POST", data));服务器端:
    context.Request["key"]
      

  5.   

    [AcceptVerbs(HttpVerbs.Post)]
    public void Push(string id) {
    string appName = id.Split('.')[0];
    string targetFolder = Path.Combine(Server.MapPath("/Apps"), appName);
    if (!Directory.Exists(targetFolder)) {
    Directory.CreateDirectory(targetFolder);
    } var buffer = new byte[4096]; using (FileStream fs = new FileStream(Path.Combine(targetFolder, id), FileMode.Create)) {
    while (true) {
    int r = Request.InputStream.Read(buffer, 0, 4096);
    if (r <= 0) { break; }
    fs.Write(buffer, 0, r);
    }
    }
    }