一个接收Post来数据的问题

最近在做工行银企互联接入的项目,工行会主动把数据通过post的方式,发送到我们的一个地址,地址为:http://ip:端口,我该如何获取发送过来的数据呢?折腾了半天,没搞定,头都大了,盼各位老大支招,多谢。

注:1.能否用一个默认页面(如default.aspx)来接收?

2.能否给个例子,谢谢。


牛魔王的故事
浏览 251回答 2
2回答

慕桂英4014372

在default.aspx文件中Request就能获取到了。

吃鸡游戏

POST过来的数据会放在两个地方,其中1个是Form,另一个就是InputStream&nbsp;放在InputStream的数据可以通过流的方式来读取,也可以利用Request.File[0]来获取1.客户端代码:(通过一个button触发)&nbsp;&nbsp; <script language="javascript" type="text/javascript">&nbsp;// <!CDATA[&nbsp;&nbsp; &nbsp; var xmlHttpRequest;&nbsp;function Button1_onclick()&nbsp;{&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;alert('您的浏览器不支持xml文件读取,于是本页面禁止您的操作,推荐使用IE5.0以上可以解决此问题!');&nbsp;&nbsp; }&nbsp;&nbsp; xmlHttpRequest=new ActiveXObject("Msxml2.XMLHTTP");&nbsp;&nbsp; xmlHttpRequest.onreadystatechange=handleStateChange;&nbsp;&nbsp; xmlHttpRequest.open("POST", "http://localhost/test0304/default.aspx", true);&nbsp;&nbsp; xmlHttpRequest.setRequestHeader("Content-Type","text/xml");&nbsp;&nbsp; xmlHttpRequest.send(" <?xml version=\"1.0\" standalone=\"yes\" ?> <a>2 </a>");&nbsp;}&nbsp;function handleStateChange()&nbsp;&nbsp; &nbsp; {&nbsp;&nbsp;&nbsp; &nbsp; var test=xmlHttpRequest.readyState;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; if(xmlHttpRequest.readyState==4)&nbsp;&nbsp; &nbsp; &nbsp; {&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;alert(xmlHttpRequest.status);&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; if(xmlHttpRequest.status==200)&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;&nbsp; &nbsp; &nbsp; }&nbsp;&nbsp; &nbsp; }&nbsp;// ]]>&nbsp;</script>&nbsp;2.服务器端代码:(通过iis发布,虚拟路径为http://localhost/test0304/default.aspx)&nbsp;protected void Page_Load(object sender, EventArgs e)&nbsp;&nbsp; &nbsp; {&nbsp;&nbsp; &nbsp; &nbsp; if (Request.InputStream.Length != 0)&nbsp;&nbsp; &nbsp; {&nbsp;&nbsp; &nbsp; this.Request.Files[0].SaveAs("c:\\data.xml");&nbsp;&nbsp; &nbsp; &nbsp; }&nbsp;&nbsp; &nbsp; &nbsp; else&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Response.Write(" <script>alert('验证码错误') </script>");&nbsp;&nbsp; &nbsp; }
打开App,查看更多内容
随时随地看视频慕课网APP