|
楼主 |
发表于 2015-9-14 11:58:08
|
显示全部楼层
网页:
//获取Get数据
if (context.Request.HttpMethod == "GET")
{
context.Response.Write("get");//输出文本
}
else //post
{
if (zl == cpu") //查询CPU序列号
{
context.Response.Write("1111");
}
}
//程序端发送POST
string PostStr = HTTPPOST(cpu).ToString();
private static string HTTPPOST(string postdata)
{
//创建Httphelper对象
HttpHelper http = new HttpHelper();
//创建Httphelper参数对象
HttpItem item = new HttpItem()
{
URL = "http://localhost:29291/Handler1.ashx",//URL 必需项
Method = "post",//URL 可选项 默认为Get
ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
Postdata =postdata,//Post要发送的数据
};
//请求的返回值对象
HttpResult result = http.GetHtml(item);
return result.ToString();
} |
|