Pass a user defined object to ASP.NET Webmethod from jQuery, using JSON

I quickly set up this project and I was able to successfully call my web method, please adjust your code accordingly. Make sure your class property names are the same as the ones that you pass through JavaScript.


    public static Contact getContact(Contact cnt)
    { = "Abijeet Patro"; = "Blah Blah";
        return cnt;


    $(document).ready(function () {
        var cnt = {name:'Hello',phone:'Hello'};
            type: "POST",
            url: "/Default.aspx/getContact",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: JSON.stringify({'cnt':cnt}), // Check this call.
            success: function (data) {


public class Contact
    public string name { get; set; }
    public string phone { get; set; }

Web Service Called

enter image description here

You can grab the project from here. Also please use fiddler or Chrome to monitor AJAX requests/responses. I’ve added an image to show how to monitor AJAX requests using Chrome. Fiddler is even better and more detailed.

enter image description here

Leave a Comment