javascript - All variables are null at the request with Axios to ASP.Net Core Controller -


here client request code:

import request 'axios';  //...       let url = 'login/signin',                 headers = {                     headers: {                         'content-type': 'application/json'                     }                 },                 data = json.stringify( {                     name: 'danil',                     password: 'pwd'                 });       request.post(url, data, headers); 

looks fine first glance.

request pending here: enter image description here

but ended in controller:

enter image description here

here's code btw:

[httppost]         public async task<actionresult> signin([frombody]string name, [frombody]string password)         {              var userlogincommand = new userlogincommand {                 login = name,                 password = password             };              await _dispatcher.dispatchasync(userlogincommand);             return content(userlogincommand.result, "application/json");         } 

whats wrong it? did forgot?

i tried play around json.stringify adding , removing, tried not sending headers (and throws 415 error) no changes there. still got nulls.

upd: ali suggested in comments, passing data goes fine if use loginmodel that:

 public class loginmodel         {             public string name { get; set; }             public string password { get; set; }         } 

enter image description here

but why it's not going work in simple way?


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -