不传参数名获取参数(前、后台代码)

js

  var xhr = new XMLHttpRequest();
        xhr.open("post", "/Home/NoParamTest", true);
        //两种协议都可以
        xhr.setRequestHeader("Content-Type", "application/json");
        //xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        xhr.send(JSON.stringify({ a: 1, b: 2, c: 3 }));

c#后台

 public void NoParamTest()
        {            
            using (StreamReader sr = new StreamReader(Request.InputStream))
            {
         //data就是前面传过来的数据
string data = sr.ReadLine(); } }
原文地址:https://www.cnblogs.com/myesn/p/6030507.html