C# HttpRequest的一些记录总结
来源:互联网 发布:java http代理服务器 编辑:程序博客网 时间:2024/05/21 22:29
做接口的过程中,在没有修改代码的情况下,WCF突然不可用。报错为:System.Net.WebException: 基础连接已经关闭: 发送时发生错误。
HttpWebResponse resp = req.GetResponse() as HttpWebResponse;
返回的resp为NULL,郁闷了好久。。
网上查阅资料,说法非常多: 大概为这些。
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
request.ProtocolVersion = HttpVersion.Version10;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
查阅资料发现,大多跟安全协议有关。环境为.NET4.0。询问得知, HTTP请求的网页,采用SSL Protocol:TLS v1.2,
我的代码为:
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
不满足此安全协议。查阅资料,得到:
ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072;
经本机环境测试,可以。。待客户环境测试后,看效果。。。再来更新。。
然而,客户那继续报错。。。
(一)
连接WCF时出现如下错误信息:
The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.
由于内部错误,无法处理请求。
处理办法:
<behavior> <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 --> <serviceDebug includeExceptionDetailInFaults="true"/> </behavior>
(二)the requested security protocol is not supported
不支持此种安全协议。。客户装的.NET 4.0 。。所以,服务器不支持。。。怎么办?
- C# HttpRequest的一些记录总结
- HttpRequest的一些常用方法
- Python模拟HttpRequest的方法总结
- C#手动创建HttpRequest
- C#窗体的一些总结
- C# 反射的一些总结
- c#反射的一些总结
- C#的一些基础知识点记录
- 一个封装好的Asp.Net C# HttpRequest请求类
- 关于一些编程问题的记录总结
- C# HttpRequest 中文编码问题
- c#一些常用的正则表达式总结
- c#一些常用的正则表达式总结
- 对于初学者总结的一些C#问题
- C#中mapxtreme使用的一些总结
- c# winform 使DataGridView的一些总结
- django的HTTPREQUEST对象
- django的HTTPREQUEST对象
- 命名空间、反射机制
- 场景测试用例注意点总结
- 栈的应用(进制转换)
- 22年的梦想《仙剑奇侠传》
- Server MyEclipse Tomcat v7.0 was unable to start within 45 seconds. If the server requires more time
- C# HttpRequest的一些记录总结
- 栈的应用(括号匹配)
- IOError: [Errno 13] Permission denied
- Chapter2.2 JVM内存管理二
- <script>元素
- JSP学习笔记1
- 数据库与机器对比的差异性详解
- vue2开发之实现可复用的轮播图carousel组件
- 函数类型+WINAPI+函数名