httpWebRequest 错误

在模拟提交的时候400错误多是由于客户端的请求不完整照成的,

可以参考以下代码将请求信息补充完整

<textarea cols="50" rows="15" name="code" class="c-sharp:nogutter"> httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.AllowAutoRedirect = false; httpWebRequest.Accept = "*/*"; httpWebRequest.Headers.Add("Accept-Language", "zh-cn"); httpWebRequest.Headers.Add("Accept-Encoding", "gzip, deflate"); httpWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)"; httpWebRequest.KeepAlive = true; httpWebRequest.Timeout = 300000; httpWebRequest.Method = "GET"; </textarea>

500错误是由于服务端处理错误返回的,很多可能就是你的post信息没有进行

UrlEncode编码,编码以下解决,或者是post信息部正确。

0
时间: 2024-08-05 15:15:04

httpWebRequest 错误的相关文章

(微信API接口开发) 使用HttpWebRequest进行请求时发生错误:基础连接已关闭,发送时发生错误处理

最近调试原来的微信模拟登陆时发生了"基础连接已关闭,发送时发生错误"的错误提示,原来都是好好的,只是很久没用了. 出错代码如下: ? 1 2 3 4 5 6 7 HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("https://mp.weixin.qq.com/cgi-bin/loginpage?t=wxm2-login&lang=zh_CN");///cgi-bin/loginpage?

httpWebRequest请求错误,基础连接已经关闭: 连接被意外关闭

win10下,C# 用httpWebRequest 执行post请求出现"请求错误,基础连接已经关闭: 连接被意外关闭",经测试设置 //Post请求方式 System.Net.HttpWebRequest request;            request = (System.Net.HttpWebRequest)WebRequest.Create(strURL);            //Post请求方式            request.Method = "P

HttpWebRequest 基础连接已经关闭: 接收时发生错误

HttpWebRequest request = null; Stream webStream = null; HttpWebResponse response = null; StreamReader reader = null; string responseString = ""; try { byte[] bf = Encoding.UTF8.GetBytes(postString); request = WebRequest.Create(url) as HttpWebReq

C#使用HttpWebRequest 进行请求,提示 基础连接已经关闭: 发送时发生错误。

本人今天遇到的错误,C#使用HttpWebRequest 进行请求,提示 基础连接已经关闭: 发送时发生错误. 测试了很久,才发现,是安全协议问题,把安全协议加上就可以了 请求的地址安全协议可能也不一样, ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls

在使用 HttpWebRequest Post数据时候返回 400错误

笔者有一个项目中用到了上传zip并解压的功能.开始觉得很简单,因为之前曾经做过之类的上传文件的功能,所以并不为意,于是使用copy大法.正如你所料,如果一切很正常的能运行的话就不会有这篇笔记了. 整个系统跑起来以后,在本地开发环境中测试,顺利执行.测试环境中,顺利执行.随着项目的推进,上线.这个功能在前期本身是不重要的,不过当你没有服务器权限的时候,有一个可以随意上传文件的功能还是很不错的,再也不用写邮件,等待,等待,等待,而是可以很快看到修改结果,这样想想还是令人小激动的. so? 出来什么问

[转载]使用HttpWebRequest进行请求时发生错误:基础连接已关闭,发送时发生错误处理

转载,原文来自 http://blog.csdn.net/hawksoft/article/details/21776009 最近调试原来的微信模拟登陆时发生了“基础连接已关闭,发送时发生错误”的错误提示,原来都是好好的,只是很久没用了. 出错代码如下: HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("https://mp.weixin.qq.com/cgi-bin/loginpage?t=wxm2-login&la

(转)HttpWebRequest以UTF-8编码写入内容时发生“Bytes to be written to the stream exceed the Content-Length bytes size specified.”错误

from:http://www.cnblogs.com/Gildor/archive/2010/12/13/1904060.html HttpWebRequest以UTF-8编码写入内容时发生“Bytes to be written to the stream exceed the Content-Length bytes size specified.”错误 出错代码如下: request.ContentLength = Encoding.UTF8.GetByteCount(content);

C# .Net FrameWork3.5中异步HTTP请求时,由于安全协议的问题System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)方法抛出“基础连接已经关闭: 发送时发生错误”的解决办法

现象描述: C# .Net FrameWork3.5中异步HTTP请求时,由于安全协议的问题System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)方法抛出“基础连接已经关闭: 发送时发生错误”. 原因分析: 大多数情况下是由于客户端所设置的HTTP访问请求的安全协议不符合服务器端的安全协议要求.比如,NASA提供瓦片服务的http://worldwind25.arc.nasa.gov/wms?service=WMS&v

HttpWebRequest 和 HttpWebResponse 的应用

转载:http://www.cnblogs.com/yiki/archive/2007/08/28/872528.html HttpWebRequest request = (HttpWebRequest)WebRequest.Create(addr);// Downloads the XML file from the specified server.HttpWebResponse response = (HttpWebResponse)request.GetResponse();Syste