JSON パラメータを asp.net C# に渡しています。パラメータは単一または複数のデータです。
そのため、パラメーターを LIST クラス型として受け取るコードを記述します。
しかし、 「オブジェクト参照がオブジェクトのインスタンスに設定されていません」というエラーが返されます。
このようなテストコードを書くと、同じエラーが発生します。
私のコードを見直して、私にアドバイスしてください。
テストコード、
コントローラークラスで
[HttpGet]
public ActionResult modelTest(TestList obj)
{
return Content(obj.wow.Count.ToString());
}
モデルとリストクラス、
public class TestList
{
public List<TestModel> wow { get; set; }
}
public class TestModel
{
public string id { get; set; }
public string name { get; set; }
}
/Test/modelTest/?id=myId&name=john&age=11を呼び出します
その後、エラーが発生し、
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 338: {
Line 339:
Line 340: return Content(obj.wow.Count.ToString());
Line 341: }
Line 342: