c# - ASP.NET5 MVC6: Pass object from view to controller always null -


edit: able pass plain data if use type: 'get' in ajax call , [httpget] in controller.

however, complex datatypes summary class still not working , either 0 or null.

i have following class:

public class summary     {         public int total { get; set; }         public double average { get; set; }         public int issues { get; set; }         public int fixed { get; set; }         public double fixedpercentage { get; set; }         public double totalpercentage { get; set; }         public list<issues> issueslist { get; set; }             }  public class issues {        public string name {get; set;}        public int code {get; set;} } 

and following action on controller:

[httpget] public iactionresult getsummary(summary summarybysource) {      json(new      {          summary = "hi"      }); } 

lastly, ajax call using return object controller:

$.ajax({         type: 'get',         datatype: 'json',         url: '/summary/getsummary/',         data: json.stringify(summarybysource),         error: function (xhr) {             alert("wrong");         },         success: function (result) {             alert("yeah");          },         async: true,         processdata: true     }); 

once ajax call gets called, jumps controller function properties null. why happening?

btw: variable summarybysource global variable in view @ moment ajax call called , contains values matches summary object.

also, tried same thing instead of passing object, dumb string , returns null...

thanks!

edit: content of summarybysource is

it object type and...

total: 0 average: 0 issues: 2 fixed: 1 fixedpercentage: 50 totalpercentage: 100 issueslist: array[1]     0: object         name: "crash"         code: 1001 


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -