.NET web service gets null object

I’m trying to save an object using ajax call and .NET REST web service but I get null object on .NET side. Please help me to find out what’s the issue.

C# Object:

public class Customer
    public int Id { get; set; }

    public string Name { get; set; }

Web service:

        [WebInvoke(UriTemplate = "SaveCustomer", BodyStyle = WebMessageBodyStyle.Wrapped,
           RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
           Method = "POST")]
        bool SaveCustomer(Customer c);

AJAX Call:

var type = "POST";
var url = "/WS/Service.svc/SaveCustomer";
var contentType = "application/json; charset=utf-8";
var dataType = "json";
var data = '{ "c:":{"Id": "1", "Name": "myname"}';
var processData = true;

    type: type, 
    url: url, 
    data: data, 
    contentType: contentType, 
    dataType: dataType, 
    processdata: processData, 
    success: function (msg) {
    error: function (error) {

using that I get null when debugging:

public bool SaveCustomer(Customer c)
    return true;

Source: .net

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.