展开全部
string URL = "www.xxx.com";
public void sendPost(string urlArgs,HttpContext context)
{
//context.Request["args"]
System.Net.WebClient wCient = new System.Net.WebClient();
wCient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
byte[] postData = System.Text.Encoding.ASCII.GetBytes("id=" + urlArgs);
byte[] responseData = wCient.UploadData(URL, "POST", postData);
string returnStr = System.Text.Encoding.UTF8.GetString(responseData);//返回接受的数据
context.Response.ContentType = "text/plain";
context.Response.Write(returnStr);
}
除了上面的方法还有可以使用62616964757a686964616fe59b9ee7ad9431333361323563JSONP来实现,具体应用JSONP实现Json数据跨域调用,需要服务器端与客户端的合作完成。关于JSONP的具体使用方式,网上有很多相关的资料可以参考。这里就暂时做个记录,以后用到的话再具体分析。