【发布时间】:2021-08-15 00:24:30
【问题描述】:
我正在尝试使用 ASP.net 进行发布请求,我正在运行我的 web api,并且我有我的应用程序,我通过我的方法调用 api,我尝试使用 Http 客户端和这是我的控制器
public async Task<ActionResult> Create()
{
var user = new LutUsers();
var jsonString = System.Text.Json.JsonSerializer.Serialize(user);
var stringContent = new StringContent(jsonString, Encoding.UTF8, "application/json");
var response = await client.PostAsync(client.BaseAddress + "/user/findusers", stringContent);
Response.Write(response);
if (response.IsSuccessStatusCode)
{
//Storing the response details recieved from web api
Response.Write("<script>alert('Connection Made successfully!');</script>")
}
return View();
}
Response.write(respon)
给我这个错误:StatusCode: 405, ReasonPhrase: 'Method Not Allowed', Version: 1.1, Content: System.Net.Http.StreamContent
有人可以帮我找出我做错了什么吗?谢谢
【问题讨论】:
标签: c# asp.net .net post asp.net-web-api