大家好,我需要帮助..我总是收到 405 Method Not Allowed
我正在使用 Asp.Net Core Web 应用程序 3.1,我的 HttpGet 没有问题,但当我使用 HttpPost 时,它总是返回 405 状态代码
这是我的控制器
[Route("api/[controller]")]
[ApiController]
public class ExamController : ControllerBase
{
[HttpPost("PostValue")]
public ActionResult<HttpResponseMessage> PostInfo([FromBody] PersonalInfo info)
{
string json = JsonConvert.SerializeObject(info);
HttpClient client = new HttpClient();
var response = client.PostAsync("https://sampleapi/receive", new StringContent(json, Encoding.UTF8, "application/json"));
if (response.IsFaulted)
return BadRequest(response);
return Ok(response);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的创业班
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) …Run Code Online (Sandbox Code Playgroud)