C# Paypal错误从Asp.net中的传输流接收到意外的EOF或0字节
我在api-3t.sandbox.paypal.com中调用SetExpressCheckout时收到此错误,从传输流接收到意外的EOF或0字节。我正在使用Asp.net调用api 这是我的密码:C# Paypal错误从Asp.net中的传输流接收到意外的EOF或0字节,c#,asp.net,paypal,paypal-sandbox,C#,Asp.net,Paypal,Paypal Sandbox,我在api-3t.sandbox.paypal.com中调用SetExpressCheckout时收到此错误,从传输流接收到意外的EOF或0字节。我正在使用Asp.net调用api 这是我的密码: private static NameValueCollection Submit(string values) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create( String.Format("https:
private static NameValueCollection Submit(string values)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(
String.Format("https://{0}/nvp", PayPalSettings.ApiDomain));
request.Method = "POST";
request.ContentLength = values.Length;
using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
{
writer.Write(values);
}
WebResponse webResponse = request.GetResponse();
Stream response = webResponse.GetResponseStream();
using (StreamReader reader = new StreamReader(response))
{
return HttpUtility.ParseQueryString(reader.ReadToEnd());
}
}
调用request.GetRequestStream()时会发生错误
值参数包含:
USER=谢谢。经过一些研究,我发现了。 显然,几个月前,
paypal
更改了支持的TLS版本,使版本1.2成为支持的最低版本
问题是.Net Framework 3.5不支持该版本。
对于高于3.5的框架,可以添加下一行:
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
由于这个问题几乎是一年前的问题,我认为微软不会对fw 3.5进行更新,因此我建议将你的应用程序迁移到4.5。你可能需要检查你的环境,Paypal最近在沙箱环境中增强了安全性。请参阅@ZhaoSamanta-感谢你分享的信息。但是,如果Paypal增强了沙盒环境的安全性。他们不应该对其live环境也做同样的增强。当我阅读PayPal API文档时,他们建议在开发时使用沙盒环境,完成后只需切换到live环境。目前我的web应用程序在live环境中工作。当我发布URL(用于沙盒)直接连接到浏览器也可以。非常感谢您或任何人提供的任何帮助。谢谢。PayPal首先在沙盒环境中进行更改,让商家知道更改。Live环境将在稍后更改,可能在今年6月。VB版本:System.Net.ServicePointManager.SecurityProtocol=System.Net.SecurityProtocolType.Tls12