我尝试登录到某个功能但由于错误意外无法登录。 [英] I tried login to a function but unexpectedly unable to login due to error.

查看:70
本文介绍了我尝试登录到某个功能但由于错误意外无法登录。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  try  
{
HttpWebRequest request =(HttpWebRequest)WebRequest.Create(url);
request.Method = apiCallMethod;
request.ContentType = application / json;
request.Accept = en_US;
request.Headers.Add( X-Api-Version: + xApiVersion);
var temp = ;
// request.Headers.Add(X-Api-Version:+ xApiVersion);
// request.Headers.Add(auth:+ sessionID);
// if(apiCallMethod ==POST)
// {
// using(var streamWriter = new StreamWriter(request.GetRequestStream()))
// {
// streamWriter.Write(json);
// streamWriter.Flush();
// streamWriter.Close();
// }
// }
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
request.Timeout = 300 ;
HttpWebResponse response =(HttpWebResponse)request.GetResponse();
string 结果;





我有什么试过:



行上出错

 HttpWebResponse response =(HttpWebResponse)request.GetResponse(); 



错误 - 基础连接已关闭接收上发生意外错误

解决方案

发生这种情况时,表示远程服务器强行终止了连接。每当我看到这个,通常是因为调用代码传递的错误URL导致服务器端出现硬故障,存在配置问题(例如没有提供有效的auth令牌)或者存在问题远程服务器。无论哪种方式,您在此处显示的代码都不会帮助您,因为您错过了URL。如果您可以保证URL正确并且您已经满足了您的所有条件,那么您将不得不与调用链另一端的人员一起工作,找出他们最终的错误。

try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = apiCallMethod;
                request.ContentType = "application/json";
                request.Accept = "en_US";
                request.Headers.Add("X-Api-Version:" + xApiVersion);
                var temp = "";
                //request.Headers.Add("X-Api-Version:" + xApiVersion);
                //request.Headers.Add("auth:" + sessionID);
                //if (apiCallMethod == "POST")
                //{
                //    using (var streamWriter = new StreamWriter(request.GetRequestStream()))
                //    {
                //        streamWriter.Write(json);
                //        streamWriter.Flush();
                //        streamWriter.Close();
                //    }
                //}
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
                request.Timeout = 300;
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                string result;



What I have tried:

Error on line

HttpWebResponse response = (HttpWebResponse)request.GetResponse();


Error- the underlying connection was closed unexpected error occurred on a receive

解决方案

When this happens, it means that the remote server has forcefully terminated the connection. Whenever I have seen this, it has usually been because the calling code was passing an incorrect URL that caused a hard failure at the server side, there was a configuration issue (such as not supplying valid auth tokens) or there was a problem with the remote server. Either way, the code you have shown here isn''t going to help you because you are missing the URL. If you can guarantee that the URL is correct and that you have satisfied all the conditions on your side, you are going to have to work with the people at the other side of the calling chain to work out what''s wrong at their end.


这篇关于我尝试登录到某个功能但由于错误意外无法登录。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆