首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

js中XMLHttpRequest请求.ashx页面,在C#顶用哪个

2012-11-07 
js中XMLHttpRequest请求.ashx页面,在C#中用哪个在C#中用哪个可以实现与js中XMLHttpRequest对象一样以get方

js中XMLHttpRequest请求.ashx页面,在C#中用哪个
在C#中用哪个可以实现与js中XMLHttpRequest对象一样以get方式请求页面

[解决办法]

C# code
  StringBuilder builder = new StringBuilder();         builder.Append("http://xxx.com.cn/misc.ashx");         builder.Append("?");         builder.Append("action=gold");         builder.Append("&");         builder.Append("token="+strToken+"");         HttpWebResponse rsp = null;         HttpWebRequest req = null;         req = (HttpWebRequest)WebRequest.Create(new Uri(builder.ToString()));         req.ContentType = "application/x-www-form-urlencoded";         req.Accept = "*/*";         req.Timeout = 30000;//30秒连接不成功就中断         req.Method = "GET";         rsp = (HttpWebResponse)req.GetResponse();         Stream rspStream = rsp.GetResponseStream();         StreamReader sr = new StreamReader(rspStream, Encoding.GetEncoding("utf-8"));         result = sr.ReadToEnd();         sr.Close();               XmlDocument xmlDoc = new XmlDocument();         xmlDoc.LoadXml(result); 

热点排行