猿问

Asp.net Core 2 API POST对象是否为NULL?

我有一个带有某些测试功能的.net Core 2 API设置。(Visual Studio 2017)


使用邮递员,我将原始数据发布到该方法,但是模型只是空白?为什么?


        // POST api/Product/test

        [HttpPost]

        [Route("test")]

        public object test(MyTestModel model)

        {

            try

            {

                var a = model.SomeTestParam;


                return Ok("Yey");

            }

            catch (Exception ex)

            {

                return BadRequest(new { message = ex.Message });

            }

        }


        public class MyTestModel

        {

            public int SomeTestParam { get; set; }


        }

http://img3.mukewang.com/5daf05af0001f4a408140387.jpg

阿晨1998
浏览 953回答 2
2回答
随时随地看视频慕课网APP
我要回答