.net 基础连接已经关闭 连接被意外关闭 怎么搞
我通过网络去获取信息,在一台server08上工作完全正常,另一台老这样“基础连接已经关闭连接被意外关闭”。有时候会正常,但我也不知道为什么。Stringurl=APPL...
我通过网络去获取信息,在一台server 08上工作完全正常,另一台老这样“基础连接已经关闭 连接被意外关闭”。有时候会正常,但我也不知道为什么。
String url = APPLICATION_TOKEN_URL;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback((s, c1, c2, e) => true);
HttpWebRequest hwr = WebRequest.Create(url) as HttpWebRequest;
hwr.ProtocolVersion = HttpVersion.Version10;
hwr.Method = "POST";
hwr.ContentType = "application/x-www-form-urlencoded";
hwr.Headers.Add("Authorization: Basic " + APPLICATION_AUTH);
string postdata = "grant_type=client_credentials";
byte[] data = Encoding.UTF8.GetBytes(postdata);
using (Stream stream = hwr.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var result = hwr.GetResponse() as HttpWebResponse;
异常就出在最后一句上:基础连接已经关闭 连接被意外关闭 展开
String url = APPLICATION_TOKEN_URL;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback((s, c1, c2, e) => true);
HttpWebRequest hwr = WebRequest.Create(url) as HttpWebRequest;
hwr.ProtocolVersion = HttpVersion.Version10;
hwr.Method = "POST";
hwr.ContentType = "application/x-www-form-urlencoded";
hwr.Headers.Add("Authorization: Basic " + APPLICATION_AUTH);
string postdata = "grant_type=client_credentials";
byte[] data = Encoding.UTF8.GetBytes(postdata);
using (Stream stream = hwr.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var result = hwr.GetResponse() as HttpWebResponse;
异常就出在最后一句上:基础连接已经关闭 连接被意外关闭 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询