asp.net mvc - Empty model properties when posting to a controller action -


i trying post controller action , have model populated correctly, empty model both of properties set null.

here's parameter model:

public class loginviewmodel {     public string username;     public string password; } 

here action:

[httppost] public httpresponsemessage login(loginviewmodel model) {     // model.username , model.password null reason } 

here's route config:

config.routes.maphttproute(     name: "authapi",     routetemplate: "api/login",     defaults: new     {         controller = "apiaccount",         action = "login"     } ); 

here's request:

post /api/login http/1.1 host: localhost:51444 cache-control: no-cache content-type: application/x-www-form-urlencoded  username=me&password=testfake 

what's wrong here?

try adding get/set view model:

public class loginviewmodel {     public string username { get; set; }     public string password { get; set; } } 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -