下面的代码,为什么不能取得HTTP返回数据?

ynduanlian ynduanlian 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
下面的代码,为什么不能取得HTTP返回数据?
运行后超时报错,但是,如果我把这个URL直接在浏览器中输入,是可以返回结果的:

       private void button1_Click(object sender, EventArgs e)
{
string StrURL = @"https://translate.google.cn/translate_a/single?client=t&sl=en&tl=zh-CN&hl=en&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&otf=1&ssel=0&tsel=0&kc=1&tk=265721.161153&q=Custodian%3a";
HttpWebRequest WebRequest1 = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(StrURL);
WebRequest1.Method = "GET";

HttpWebResponse webResponse = (System.Net.HttpWebResponse)WebRequest1.GetResponse();
MessageBox.Show(webResponse.StatusCode.ToString());
}
...全文

相关推荐

评论 8
收藏 已收藏
分享
返回顶部
ynduanlian
C# 111,128 成员 642,537 内容