Question

I'm hoping to get some help - I'm trying to send a request to my .asmx web service from Kendo grid. I have a version working without parameters, but I have not been able to pass in parameters to my web service, or at least known how to retrieve them. (NOTE: Edited to reflect solution)

// 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;
}

}

Was it helpful?

Solution

Your data should be in querystring format:

data: "guid=" + guid + "&name=" + name + "&origin=" + origin .....
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top