输入String propertyId = request.getParameterValues(propertyId);或String propertyId = request.getParameterValues(propertyId );
这两种方法都可以,只是适用的的方式不同。
post方法:
///
使用post方法,调用短信接口
///
///
///
///
///
private void CallMsgCenterToSendMsgPost(string PhoneNumber,
string SmsContent, string PhoneNumberType, string SmsUser)
{
string formUrl =
ConfigurationSettings.AppSettings["formUrl"].ToString().Trim();//url
地址
string formData = "PhoneNumber=" + PhoneNumber +
"&SmsContent=" +SmsContent + "&PhoneNumberType=" + PhoneNumberType +
"&SmsUser=" + SmsUser + "";
CookieContainer cookieContainer = new CookieContainer()
//添加程序集System.Web.Extensions.dll
using System.Web.Script.Serialization;
JavaScriptSerializer js = new JavaScriptSerializer();
剩下的,就看你有没有与传递过来的json对应的实体类了,如果没有,那你只能把传递过来的数据反序列化为字典格式。
asp.net接收post方式传过来的json格式并处理:
1、定义json:
var account = {
number : "123456",
name: "Justin",
balance: "1000"
};
2、发送post请求:
function handleAccount() {
var json = prepareJSON();
var url = "Handler1.ashx?timeStamp" + new Date().getTime();
createXMLHttpRequest();
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("POST", url);
xmlHttp.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
xmlHttp.send(account );
}
3、Handler1中的中ProcessRequest代码如下:
public void ProcessRequest(HttpContext context)
{
HttpRequest request = context.Request;
Stream stream = request.InputStream;
string json = string.Empty;
string responseJson = string.Empty;
if (stream.Length != 0)
{
StreamReader streamReader = new StreamReader(stream);
json = streamReader.ReadToEnd();
Person person = JSONHelper.Deserialize
person.FirstName = "FN";
person.LastName = "LN";
responseJson = JSONHelper.Serialize
}
if (!string.IsNullOrEmpty(responseJson))
{
context.Response.ContentType = "text/plain";
context.Response.ContentType = "UTF-8";
context.Response.Write(responseJson);
}
}