这是我写的控制器
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
namespace PopUpByMessage.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class MyWebApiController : ControllerBase
{
private readonly ILogger<MyWebApiController> _logger;
public MyWebApiController(ILogger<MyWebApiController> logger)
{
_logger = logger;
}
//[HttpPost("[action]")]
//public IActionResult SayHello([FromBody] UserModel model)
//{
// return new JsonResult($"Hello {model.UserName}");
//}
[HttpPost("[action]")]
public IActionResult SayHello(string pwd, string data)
{
if (pwd != "1")
{
object obj = new
{
code = "0",
msg = "请求失败"
};
return new JsonResult(obj);
//return new BadRequestResult();
}
else
{
object obj = new
{
code = "1",
msg = "请求成功"
};
return new JsonResult(obj);
}
}
}
}
然后我在postman测试,不管怎么样都是code=0,请求失败,请问为什么