私はMVCとモデルバインディングに本当に慣れていないので、何か些細なことを間違っていると思います。いくつかのデータをバインドしようとしています。
意見;
$.ajax({
url: '@Url.Action("Moo")',
type: "post",
dataType: "string",
contentType: "application/json",
data: JSON.stringify({"test": "bar", "test2": "bar2"}),
success: function (data) {}
});
モデル;
Public Class MyTestData
Public Property test() As String
Public Property test2() As String
End Class
コントローラ;
Function Moo(test As MyTestData) As ActionResult
Return View()
End Function
ダバガーを実行すると、コントローラーのテストから「何も」受信しません。1 つの文字列のみを試してみると、コードが機能します (ビューのデータが {(test:bar)} に変更され、コントローラーのデータ型が MytestData から MytestData に変更されました)。弦)。
任意の入力が評価されます。