如何在HttpHandler ProcessRequest中获取字符串数组值。

时间:2015-10-06 11:22:40

标签: javascript c# jquery asp.net httphandler

我将strng数组值传递给handler。但是我无法在HttpHandler ProcessRequest中读取这些值。我怎样才能获得这些价值。?

客户端代码:

var advSearchTypes=["abc","def","ghi","jkl"]; $.ajax({ url: 'SearchHandler.ashx', type: 'post', data: ({"SearchKey": searchKey,"AdvSearchTypes": advSearchTypes}),
    success: function (response) { }, error:function(){ } });

处理程序代码:

public void ProcessRequest(HttpContext context) { 
    string aSearchKey = context.Request.Form["SearchKey"].ToString();

    string[] aSearchTypes = context.Request.QueryString["AdvSearchTypes"].Split(','); }

context.Request.QueryString["AdvSearchTypes"]显示为空。

如何获取字符串数组值??

1 个答案:

答案 0 :(得分:1)

你可以在这里改变

type=postget

var advSearchTypes=["abc","def","ghi","jkl"]; $.ajax({ url: 'SearchHandler.ashx', type: 'get', data: ({"SearchKey": searchKey,"AdvSearchTypes": advSearchTypes}),
    success: function (response) { }, error:function(){ } });

或处理程序代码

public void ProcessRequest(HttpContext context) { 
    string aSearchKey = context.Request.Form["SearchKey"].ToString();

    string[] aSearchTypes = context.Request.Form["AdvSearchTypes"].Split(','); }