enyo.ajax POST error

edited December 2013 in Newbie Questions
I have a web service developed with ASP.NET Web API it has a method(Authenticate method) which takes a class parameter;

The web api Authenticate method paremeter C# Class;
public class User
    {
        public int UserId { get; set; }
        public string Name { get; set; }
        public string Password { get; set; }
        public bool Status { get; set; }
    }
The javascript class(I want to POST this class to my service);
var User = {
    UserId: 1,
    Name: "Test",
    Password: "123",
    Status: true,
}
The enyo code;
doLogin: function () {
         
        var serviceUrl = "http://localhost/User/Authenticate";

        var ajax = new enyo.Ajax({
            url: serviceUrl,
            method: 'POST',
            handleAs: "json"
        });
        ajax.go(User);
        ajax.response(this, "processResponse");
        ajax.error(this, "processError");
    },
    processResponse: function (inSender, inResponse) {
        alert("sucess" + inResponse);
    },
    processError: function (inSender, inResponse) {
        alert("Error!");
    }
When I open chrome Network tab and I see this code request to service a Request URL like

http://localhost/User/Authenticate?UserId=1&Name=Test&Password=123&Status=true
and I see Request Method:POST on chrome network tab.
The service waits a request with class paremeter. so it returns 500 Internal Server Error.

Why this enyo code is using like GET request? Is'nt possible a class paremeter with enyo.ajax? Why chrome netword ab says this is a POST request?

Sorry for lots of questions.. I am newbie and confused...

Comments

Sign In or Register to comment.