1,配置路由
在 Startup 类下的 Configure 函数下添加
app.UseMvc(routes=>
{
routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}");
});
3,
[HttpPost]
public IActionResult Index()
{
HttpContext.Response.ContentType = "application/json";
string json = "";
using (var sr = new StreamReader(Request.Body,Encoding.UTF8))
{
var v =sr.ReadToEndAsync();//或者sr.ReadToEnd()
v.Wait();
json = v.Result;
}
return Content(json);
}