相关疑难解决方法(0)

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

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

使用postman我用一个原始数据发布到该方法的帖子,但模型只是空白?为什么?

        // 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; }

        }
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

在此输入图像描述

c# api asp.net-core

15
推荐指数
1
解决办法
9573
查看次数

标签 统计

api ×1

asp.net-core ×1

c# ×1