How can I post json object with inserted object? My code: Models code:
public class MyModel
{
public string Text { set; get; }
public int Param { set; get; }
public InsertedModel insert { set; get; }
}
public class InsertedModel
{
public string InsertedString { set; get; }
}
JavaScript code:
<script>
function createPost() {
$.ajax({
type: "POST", url: "/",
success: function (data) { alert('data: ' + data); },
data: { "Text": "Some Name", "Param": 30, "insert": { "InsertedString": "123" } },
accept: 'application/json'
});
}
</script>
Controller code:
[HttpPost]
public void Index(Models.MyModel postReq)
{
//breakpoint
}
In breakpoint i see:
Param: 30
Text: "Some Name"
insert: {Models\InsertedModel}
insert.InsertedString: null
Please help me. What I need to do with this? How can I see all my JSON struct in C# HTTPPost function?