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.
but ended in controller:
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; } }
but why it's not going work in simple way?
Comments
Post a Comment