js相似于这样:app
function send() { var xhr = new XMLHttpRequest(); xhr.open("post", "AjaxTest.aspx", true); //xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState===4) { alert("接受到的文本是:"+xhr.responseText); } } xhr.send("name=" + document.getElementById("name").value); }
因为在发送请求的时候没有指定Content-Type,因此用不管时用Request.Form没法得到这些参数,由于Request.Form只会解析Content-Type 值为“application/x-www-form-urlencoded”或“multipart/form-data”时的参数。post
但要想得到这些参数能够Request.InputStream获得:url
if (Request.InputStream.Length>0) { StreamReader sr = new StreamReader(Request.InputStream); var requestStr = sr.ReadToEnd(); }