ASP.NET Core 2.2 基础知识(十四) WebAPI Action返回类型(未完待续)

要啥自行车,直接看手表

        //返回基元类型
        public string Get()
        {
            return "hello world";
        }
        //返回复杂类型
        public Person Get()
        {
            return new Person {Id = 1, Name = "refuge"};
        }
        //控制器需要继承  Controller 类
        public IActionResult Get()
        {
            return Ok("hello world");
        }

        //控制器需要继承  Controller 类
        public IActionResult Get()
        {
            return BadRequest("hello world");
        }

        //控制器需要继承  Controller 类
        public IActionResult Get()
        {
            return NotFound("什么也没有");
        }

猜你喜欢

转载自www.cnblogs.com/refuge/p/10234781.html