客户端 用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) 如何接收和处理 发送过来的数据?
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) 如何接收和处理 发送过来的数据?
我没有用WebForm 直接是ashx
怎么接收啊
context.Request.Form.Count
为什么啊?
HttpContext.Request.Form 取不到,还有其它方法吗,谢谢
WebClient wb = new WebClient();
data.Add("key", "Value");
string temp = Encoding.UTF8.GetString(wb.UploadValues(url, "POST", data));服务器端:
context.Request["key"]
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);
}
}
}