How to pass a json object to a method in asp.net mvc 4? -


i'm trying pass json object method in asp.net mvc 4 return null.

how ?

trying

asp.net method

    [webmethod]     public jsonresult dologinapp(string model){                              jsonresposta.add("status", "1");         jsonresposta.add("email", model);         return json(jsonresposta);     } 

json object

{"user": {"email":"myemail@domain.com", "password":"xxxxx"}}; 

return

{     "status": "1",     "email": null } 

url

http://localhost:14807/user/dologinapp 

edit post

model

public class userjsonmodel{      public long id                  { get; set; }              public string nome              {   get;set;}                 public string email             {get;set;}         public string senha             {get;set;}        public int status               { get; set; } //1 ativo, 2 inativo, 0 aguardando     public int tipo                 { get; set; } //1 painel, 2 aplicativos     public string imagem            { get; set; }     public int loginby              { get; set; } //0 app, 1 facebook     public userjsonmodel() { }  } 

asp.net method

    [webmethod]     [httppost]     public jsonresult dologinapp(userjsonmodel model){         jsonresposta.add("status", "1");         jsonresposta.add("email", model.email);         return json(jsonresposta);     } 

first create model map json object , define in method how pass object (ex body)

[webmethod] [httppost] public jsonresult dologinapp([frombody] mymodel model){                          jsonresposta.add("status", "1");     jsonresposta.add("email", model);     return json(jsonresposta); } 

and search in java how make httprequest post , sent data in body, , work.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -