读书人

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

发布时间: 2012-08-03 00:12:14 作者: rapoo

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

读书人网 >asp.net

热点推荐