HttpWebRequest 400错误和500错误解决方案
2010-06-10 01:36
281 查看
在模拟提交的时候400错误多是由于客户端的请求不完整照成的,
可以参考以下代码将请求信息补充完整
500错误是由于服务端处理错误返回的,很多可能就是你的post信息没有进行
UrlEncode编码,编码以下解决,或者是post信息部正确。
可以参考以下代码将请求信息补充完整
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";
500错误是由于服务端处理错误返回的,很多可能就是你的post信息没有进行
UrlEncode编码,编码以下解决,或者是post信息部正确。
相关文章推荐
- 在使用 HttpWebRequest Post数据时候返回 400错误
- HttpWebRequest的常见错误使用TcpClient可避免
- 风讯CMS提交时出现System.Web.HttpRequestValidationException (0x80004005):错误
- HttpWebRequest下载文件,乱码问题解决方案
- SSRS2008web中报表管理器无法打开 http:400错误
- 使用TcpClient可避免HttpWebRequest的常见错误
- httpWebRequest 错误
- 本地接收百度等外部文件显示结果 使用TcpClient可避免HttpWebRequest的常见错误
- HttpWebRequest的常见错误使用TcpClient可避免
- HttpWebRequest中GetResponse或者说GetRequestStream偶尔超时,或者是各种操作超时造成的假死的一些解决方案
- 解决HttpWebRequest写入数据“操作超时”错误
- HttpWebRequest请求返回非200的时候 HttpWebResponse怎么接受返回错误提示
- 错误:bad request 400(建立socket http get请求)-linux
- HttpWebRequest以UTF-8编码写入内容时发生“Bytes to be written to the stream exceed the Content-Length bytes size specified.”错误
- 使用HttpWebRequest进行请求时发生错误:基础连接已关闭,发送时发生错误处理
- https使用HttpWebRequest出现错误:System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream.的解决方法
- firefox下XMLHttpRequest重用时nsIXMLHttpRequest.send发生错误的解决方案
- HTTP 400 错误 - 请求无效 (Bad request)
- HttpWebRequest.GetResponse() raises exception when http status code 400 (bad request) is returned
- HttpWebRequest请求超时的错误