WebRequest Bug

G

Gary Brewer

I have come to the end of my ability to search for the answer to this
problem.

I am using .NET v1.1.4322 on a Windows XP 2600.xpsp2.030422-1633 : Service
Pack 1

I am connecting via an Internet Gateway also running Windows XP using a
56.5Kbps modem with an
actual connection speed of 45.2Kbps.

The code being executed is running in a new thread off of the main windows
form process. The problem appears
to start at System.Net.ConnectStream.EndReadWithoutValidation.

Doing a search at google returns two messages, one an earlier attempt by
myself to resolve the problems.

The problem only manifests itself on some web requests, the majority of the
time it works. However, opening URLs that
do not work, using programs such as Internet Explorer, work with no problems
at all!

Please see my code and tell me what I am doing wrong!



WebRequest wrq=WebRequest.Create(url);
wrq.BeginGetResponse(new AsyncCallback(respStreamLoad),wrq);


class asyncStore
{
public string data="";
public byte[] b=null;
public Stream stream;
}


protected void respStreamLoad(IAsyncResult res) {
WebRequest wrq=(WebRequest)res.AsyncState;
WebResponse resp=wrq.EndGetResponse(res);
asyncStore @as=new asyncStore();
@as.stream=resp.GetResponseStream();
@as.b=new byte[1024];
@as.stream.BeginRead(@as.b,0,@as.b.Length,new AsyncCallback(readData),@as);
}


protected void readData(IAsyncResult res) {
asyncStore @as=(asyncStore)res.AsyncState;
int [email protected](res);
if(read>0)
{
@as.data+=System.Text.ASCIIEncoding.ASCII.GetString(@as.b,0,read);
@as.b=new byte[1024];
@as.stream.BeginRead(@as.b,0,@as.b.Length,new
AsyncCallback(readData),@as);
}
else
{
@as.stream.Close();
}
}


I get the following exception on the line (int
[email protected](res);)



- ex {"The request was aborted: The request was canceled." }
System.Exception
+ [System.Net.WebException] {System.Net.WebException}
System.Net.WebException
System.Object {System.Net.WebException} System.Object
_className null string
_COMPlusExceptionCode -532459699 int
+ _exceptionMethod {System.Reflection.RuntimeMethodInfo}
System.Reflection.MethodBase
_exceptionMethodString null string
_helpURL null string
_HResult -2146233079 int
_innerException { } System.Exception
_message "The request was aborted: The request was canceled." string
_remoteStackIndex 0 int
_remoteStackTraceString null string
_source "System" string
+ _stackTrace {System.Array} System.Object
_stackTraceString " at
System.Net.ConnectStream.EndReadWithoutValidation(NestedSingleAsyncResult
castedAsyncResult)\r\n at System.Net.ConnectStream.EndRead(IAsyncResult
asyncResult)\r\n at
HZRSSNotifier.helperMods.rssLoader.readData(IAsyncResult res) in
c:\\documents and settings\\gary\\my documents\\visual studio
projects\\hzrssnotifier\\helpermods\\rssloader.cs:line 155" string
_xcode -532459699 int
_xptrs 0 int
HelpLink null string
HResult -2146233079 int
InnerException { } System.Exception
Message "The request was aborted: The request was canceled." string
Source "System" string
StackTrace " at
System.Net.ConnectStream.EndReadWithoutValidation(NestedSingleAsyncResult
castedAsyncResult)\r\n at System.Net.ConnectStream.EndRead(IAsyncResult
asyncResult)\r\n at
HZRSSNotifier.helperMods.rssLoader.readData(IAsyncResult res) in
c:\\documents and settings\\gary\\my documents\\visual studio
projects\\hzrssnotifier\\helpermods\\rssloader.cs:line 155" string
+ TargetSite {System.Reflection.RuntimeMethodInfo}
System.Reflection.MethodBase
 
Joined
Aug 5, 2006
Messages
1
Reaction score
0
I am having a similar problem with .Net 2.0 and Visual Studio's web services. How did you solve your problem? Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top