问题描述
我正在尝试将以下代码行添加到网站项目中的Global.asax文件中.
I'm trying to add the following line of code to the Global.asax file in a website project.
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
vs2012 IntelliSense显示存在Tls12定义.但是,该版本表示该定义不存在(请参见屏幕截图).
The vs2012 IntelliSense is showing that Tls12 definition exist. But the build is saying that the definition does not exist (See screen shot).
我尝试将System.Net.dll添加到项目的bin文件夹中,但是构建仍然失败.知道我怎么能解决这个问题吗?
I've tried adding System.Net.dll to the bin folder of the project, but the build still failed. Any idea how I might be able to resolve this?
推荐答案
仅在Framework 4.0上缺少SecurityProtocolType.Tls11和SecurityProtocolType.Tls12枚举值.
SecurityProtocolType.Tls11 and SecurityProtocolType.Tls12 enum values are missing on Framework 4.0 only.
SecurityProtocolType数值:
SystemDefault(0)
Ssl3(48-0x30)
Tls(192-0xC0)
在Framework 4.0上缺少Tls11(768-0x300)
框架4.0上缺少Tls12(3072-0xC00)
SecurityProtocolType numeric values:
SystemDefault (0)
Ssl3 (48 - 0x30)
Tls (192 - 0xC0)
Tls11 (768 - 0x300) missing on Framework 4.0
Tls12 (3072 - 0xC00) missing on Framework 4.0
在Framework 4.0上,如果要允许TLS 1.0、1.1和1.2,只需替换:
On Framework 4.0, if want to allow TLS 1.0, 1.1 and 1.2, just replace:
SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12
作者:
(SecurityProtocolType)(0xc0 | 0x300 | 0xc00)
这篇关于找不到System.Net.SecurityProtocolType.Tls12定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!