日期:2014-05-17  浏览次数:20530 次

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的地址吗