具体错误如图!
这是我的控制器
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using PopUpWebApi.Models;
namespace PopUpByMessage.Controllers
{
[Route("api/MyWebApi")]
[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([FromBody] UserModel model)
{
if (model.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);
}
}
}
}