简体   繁体   English

Visual Studio无法发布Web App

[英]Visual Studio Cannot Publish Web App

My ASP.NET web project is going to call the cURL using WebRequest I used to call PayPal's cURL to get the access token, hence I used the code below: 我的ASP.NET Web项目将使用WebRequest调用cURL,我曾经使用WebRequest调用PayPal的cURL来获取访问令牌,因此我使用了以下代码:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;

I can build the project and run in debug mode. 我可以构建项目并在调试模式下运行。 However, when I click Publish, Visual Studio returns the following error. 但是,当我单击“发布”时,Visual Studio返回以下错误。

'System.Net.SecurityProtocolType' does not contain a definition for 'Tls11' 'System.Net.SecurityProtocolType'不包含'Tls11'的定义

I tried to use Visual Studio 2015 & 2017 to publish the web, but still not works. 我尝试使用Visual Studio 2015和2017发布网络,但仍然无法正常工作。

能够在调试模式下运行

For the background information: My project is running .NET Framework 4.5, Windows 10 有关背景信息:我的项目正在运行.NET Framework 4.5,Windows 10

This is a known issue with .NET framework 4.5 and has an open bug. 这是.NET Framework 4.5的一个已知问题,并且存在一个开放的错误。 The issue is that the compiler does not include the int enumeration for Tls11 . 问题在于,编译器不包含Tls11int枚举。

Use this as a workaround: 使用以下解决方法:

const int SecurityProtocolTypeSsl3  = 48;
const int SecurityProtocolTypeTls11 = 768;
const int SecurityProtocolTypeTls12 = 3072;

ServicePointManager.SecurityProtocol |= (SecurityProtocolType)(SecurityProtocolTypeTls12 | SecurityProtocolTypeTls11 | SecurityProtocolTypeSsl3); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM