Answer the question
In order to leave comments, you need to log in
What should be the receiving type in the controller?
js script sends post request
to asp.net controller
$.post("/Home/Add" , {"A":"a" , "B":"b"});
[HttpPost]
public void Add(/*.....*/) {}
Answer the question
In order to leave comments, you need to log in
It must be a class with the same properties as you are sending, and the [FromBody] attribute must be added:
public class Word
{
public string A { get; set; }
public string B { get; set; }
}
[HttpPost]
public void Add([FromBody]Word word)
{
}
public class TestClass
{
public int Prop { get; set; }
}
public class Word
{
public TestClass A{ get; set; }
public string B { get; set; }
}
[HttpPost]
public void Add([FromBody]Word word)
{
}
public class Word
{
public string A{ get; set; }
}
[HttpPost]
public void Add([FromBody]IEnumerable<Word> words)
{
}
public class Word
{
[JsonProperty("OtherName")]
public string A{ get; set; }
}
[HttpPost]
public void Add([FromBody]IEnumerable<Word> words)
{
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question