请帮帮我。
发送后查询后,我有webexception“错误获取响应流(ReadDone2):接收失败”。帮助摆脱这个错误。谢谢。
一段代码
try
{
string queryContent = string.Format("login={0}&password={1}&mobileDeviceType={2}/",
login, sessionPassword, deviceType);
request = ConnectionHelper.GetHttpWebRequest(loginPageAddress, queryContent);
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())//after this line //occurs exception - "Error getting response stream (ReadDone2): Receive Failure"
{
ConnectionHelper.ParseSessionsIdFromCookie(response);
string location = response.Headers["Location"];
if (!string.IsNullOrEmpty(location))
{
string responseUri = Utils.GetUriWithoutQuery(response.ResponseUri.ToString());
string locationUri = Utils.CombineUri(responseUri, location);
result = this.DownloadXml(locationUri);
}
response.Close();
}
}
catch (Exception e)
{
errorCout++;
errorText = e.Message;
}
// Methot GetHttpWebRequest
public static HttpWebRequest GetHttpWebRequest(string uri, string queryContent)
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
request.Proxy = new WebProxy(uri);
request.UserAgent = Consts.userAgent;
request.AutomaticDecompression = DecompressionMethods.GZip;
request.AllowWriteStreamBuffering = true;
request.AllowAutoRedirect = false;
string sessionsId = GetSessionsIdForCookie(uri);
if (!string.IsNullOrEmpty(sessionsId))
request.Headers.Add(Consts.headerCookieName, sessionsId);
if (queryContent != string.Empty)
{
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
byte[] SomeBytes = Encoding.UTF8.GetBytes(queryContent);
request.ContentLength = SomeBytes.Length;
using (Stream newStream = request.GetRequestStream())
{
newStream.Write(SomeBytes, 0, SomeBytes.Length);
}
}
else
{
request.Method = "GET";
}
return request;
}
参考方案
using (Stream newStream = request.GetRequestStream())
{
newStream.Write(SomeBytes, 0, SomeBytes.Length);
//try to add
newStream.Close();
}
从.rtf文件导入数据时使用int()时出错 - python我是编码新手,可能在这里错过了一些东西。我正在尝试导入.rtf文件,但是x.append(int(row [0]))出现以下错误,但我的代码错误:ValueError: invalid literal for int() with base 10: 这是我的代码:with open('example.rtf', 'r'…
使用TaskCompletionSource.TrySetResult()时出错 - c#这是another SO question的后续问题,涉及在异步回调函数上使用异步包装器。这是它的代码(@Servy提供的出色解决方案):static Task<ObservableCollection<MyResult>> GetMyDataAsync(Params p) { var tcs = new TaskCompletion…
Xamarin Forms按钮单击事件在运行时崩溃 - c#我正在Xamarin中针对Windows,iOS和Android编辑一个应用程序。在可移植项目中,当编辑xaml文件时,我添加了以下按钮:<Button x:Name="Marker_Detection" Text="Marker Detection" Grid.Row="0" Grid.Co…
Xamarin.Forms目标框架(Kitkat)问题 - c#我有一个Xamarin Forms中的项目,该项目以Target Framework作为Oreo即8.0开始。但是我的应用程序在低端设备上经常崩溃,因此我决定降级为Android 4.4作为目标框架。我将所有的nuget软件包降级为合适的版本。但是我仍然收到以下错误:max res 19, skipping values-v21 "max res …
如何在XAML [Xamarin.Forms]中使用String以外的Type设置自定义属性值 - c#在XAML的Xamarin.Forms中,您可以编写如下内容:<Entry Keyboard="Plain" /> 我调查了Entry类,并且Keyboard属性的类型为Xamarin.Forms.Keyboard。但是,如果我创建自己的自定义ContentView并在其中写入如下内容: public static reado…