Answer the question
In order to leave comments, you need to log in
C# ASP.NET. Why is the model not being passed?
I form an object in js:
var modelTitle = "пример";
var obj = {
Name: "lalala",
Age: 3,
Count: 4
};
$.post("@Url.Action("Create", "User")",
{
title: modelTitle,
model: JSON.stringify(obj)
});
public void Create(string title, User model)
{
}
Answer the question
In order to leave comments, you need to log in
Only a STRING is passed through the web request.
public void Create(string title, User model)
What is the User type? Does ASP.Net know how to deserialize the JSON you pass into the User type?
You are passing a string (JSON.stringify), but you want to get some kind of object. Change to:
public void Create(string title, <b>string</b>model)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question