当前位置: 代码迷 >> ASP.NET >> asp.net可以兑现跨域Post吗(不用ajax)
  详细解决方案

asp.net可以兑现跨域Post吗(不用ajax)

热度:258   发布时间:2013-02-25 00:00:00.0
asp.net可以实现跨域Post吗(不用ajax)?
asp.net可以实现跨域Post吗(不用ajax)?不用传递参数,接收页面直接可以request到。

------解决方案--------------------------------------------------------
可以的。
用WebRequest就可以。
string param = "hl=zh-CN&newwindow=1";
 byte[] bs = Encoding.ASCII.GetBytes(param);
 
HttpWebRequest req = (HttpWebRequest) HttpWebRequest.Create( "http://www.google.com/intl/zh-CN/" );
 req.Method = "POST";
 req.ContentType = "application/x-www-form-urlencoded";
 req.ContentLength = bs.Length;
 
using (Stream reqStream = req.GetRequestStream())
 {
reqStream.Write(bs, 0, bs.Length);
 }
 using (WebResponse wr = req.GetResponse())
 {
//在这里对接收到的页面内容进行处理
 }
------解决方案--------------------------------------------------------
action不是post的地址吗
  相关解决方案