Object Properties null on Controller

Viewed 50

I have a problem, when I do an ajax call to my controller, my Object Vague always has the propertie Name as Null. I already try loking for erros, but I can't find any.

The class:

public class Vague : IVague

{
    public DateTime DateAcceptation { get; set; }
    public DateTime DateLivration { get; set; }
    public DateTime DateFinalisation { get; set; }
    public string Name { get; set; }
}

My Ajax Call:

$.ajax({
    type: "POST",
    url: "/Vague/Create",                
    contentType: "application/json; charset=utf-8",
    data: JSON.stringify({
        DateAcceptation: $('#defaultForm-dateAcceptation')[0].value,
        DateLivration: $('#defaultForm-dateLivration')[0].value,
        DateFinalisation: $('#defaultForm-dateFinalisation')[0].value,
        Name: $('#defaultForm-name')[0].value
    }),
    async: false,
    success: function (response) {
        if (response == 'Vague Exists') {
            alert('Vague déjà existent!')
        }
        else if (response == true) {
            alert('Vague crée')
        }
        else {
            alert('Vague non crée')
        }
        // So we don't call hide before the modal finishes loading
        setTimeout(function () {
            $("#loadMeVague").modal("hide");
        }, 500);


    },
    error: function (e) {
        // So we don't call hide before the modal finishes loading
        setTimeout(function () {
            $("#loadMeVague").modal("hide");
        }, 500);
        alert(e.responseText);
    }
});

My controller code:

[HttpPost] public ActionResult Create(Vague vague) { return Json(" ");

    }   
0 Answers
Related