javascript - Get Js FormData() In Web Api -


is there trick getting formdata post request in web api? can't seem able use namevaluecollection or formdatacollection when submitting form on frontend using js formdata(). have checked http request verify form data being passed server.

js form submit

    var formdata = new formdata();     formdata.append('email', 'email@notarealemail.com');     formdata.append('password', '123');     // submit data using xmlhttprequest 

controller web api

public ihttpactionresult checkuser(formdatacollection formdata) {      //formdatacollection , namevaluecollection don't seem return key based values } 

actually, in web api controllers should check property request information post page. next can data using appropriate method: request.content.readasbytearrayasync or request.content.readasformdataasync (it's case) or request.content.readasstreamasync, etc. depends on sent data format.

or can create class respective fields , send in json way:

public ihttpactionresult checkuser(accountdata data) {  } 

and class should like:

public class accountdata {        public string email { get; set; }        public string password { get; set; } } 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -