我试图从jQuery传递JSON到.ASHX文件。 我想通过HttpContext和猫到NameValueCollection检索.ASHX文件中的JSON数据。 这是怎么回事?将jsondata转换为NameValueCollection
$.ajax({
url: "GetLetterInformationHandler.ashx",
data: "{'Name':'david', 'Family':'logan'}",
contentType: "application/json; charset=utf-8",
type: "Get",
datatype: "json",
onSuccess: function (data) {
}
});
现在我可以使用查询字符串,并与投如下:
public void ProcessRequest(HttpContext context)
{
HttpResponse response = context.Response;
string cururl = context.Request.Url.ToString();
int iqs = context.Request.Url.ToString().IndexOf('?');
string querystring = (iqs < cururl.Length - 1) ? cururl.Substring(iqs + 1) : String.Empty;
NameValueCollection parameters = HttpUtility.ParseQueryString(querystring);
context.Response.ContentType = "text/plain";
}
我想用JSON insted的查询字符串
我使用动态parameters.Also其他地区的应用程序发送参数到ashx – ZSH