C# 接收Context-type为json的请求并获取参数

75 阅读1分钟

C# 接收Context-type为json的请求并获取参数


Stream postData = Request.InputStream;
StreamReader sRead = new StreamReader(postData);
string postContent = sRead.ReadToEnd();
sRead.Close();

其中postContent 就是你的josn字符串,

如果是mvc的话,只需要在你的Controllers 方法上面添加 [HttpPost] 就可

[HttpPost]
public string GetPostData(string josnData)

{

   //

}