Kendo网格和asmx Web服务

时间:2013-12-30 20:15:03

标签: c# web-services grid kendo-ui asmx

我希望得到一些帮助 - 我正在尝试从Kendo网格向我的.asmx网络服务发送请求。我有一个没有参数的版本,但我无法将参数传递给我的Web服务,或者至少知道如何检索它们。 (注:编辑以反映解决方案)

// Here's how the transport part of the Kendo Grid looks:

        transport: {
            read: {
                url: function (e) {
                     return "Documents.svc/Read?guid=" + guid + "&Name=" + name + "&Origin=" + origin + "&Groups=" + groups;                                             
                },
                contentType: "application/json; charset=utf-8",                     
                type: "POST" 
            },
            parameterMap: function (data, operation) {
                return JSON.stringify(data);
            }
        }



// And here's the web service:
[ServiceContract(Namespace = "")]
[ServiceBehavior(IncludeExceptionDetailInFaults = true)] 
[AspNetCompatibilityRequirements(RequirementsMode =     AspNetCompatibilityRequirementsMode.Allowed)]
public class Documents 
{

[OperationContract]
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public List<clsDocuments> Read(string guid, string name, string origin, string groups)
{
    var Guid = HttpContext.Current.Request.QueryString["guid"];
    var Name = HttpContext.Current.Request.QueryString["name"];
    var Origin = HttpContext.Current.Request.QueryString["origin"];
    var Groups = HttpContext.Current.Request.QueryString["groups"];

    List<clsDocuments> docList = Utility.GetUnreadDocuments();

    foreach (var doc in docList)
    {
        doc.Modified = DateTime.Parse(doc.Modified).ToShortDateString();
    }
   return docList;
}

}

1 个答案:

答案 0 :(得分:1)

您的数据应采用查询字符串格式:

data: "guid=" + guid + "&name=" + name + "&origin=" + origin .....