日期:2014-05-16  浏览次数:20370 次

asp.net 2.0下ashx+ajax+jquery数据获取问题
jquery ajax事件如下,传送的data参数在ashx下获取不到~  求解答!!

   $("#deleteattachment").click(function () {
            var  Requeststr=$("#<%=Label_LibNewsID.ClientID %>").attr("value");
            $.ajax({
                type: "POST",
                contentType: "application/json;charset=utf-8",
                url: "Handler.ashx?FilePath=" + $(this).prev().attr("href"),
                data: { LibNewsID: Requeststr },
                dataType: 'text',
                success: function (result) {
                     alert(result);
                },
                error: function (a, s, d) {
                    alert(s + " " + d);
                }
            });


  public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";

        string LibNewsID = context.Request.Form["LibNewsID"];
        LibNewsID = context.Request["LibNewsID"];
        LibNewsID = context.Request.Params["LibNewsID"];
        string json = new System.IO.StreamReader(context.Request.InputStream).ReadToEnd();
        context.Response.Write(json);
    }

ashx下的ProcessRequest 方法如上,data参数获取不到,得到是null,但是
 string json = new System.IO.StreamReader(context.Request.InputStream).ReadToEnd();
能得到这个data参数
具体如图:


新手求解答~
------解决方案--------------------
data: "{LibNewsID:'" +Requeststr + "'}",