works in SP1 but not SP2

coldfusion244

Well-known member
Joined
Nov 24, 2004
Messages
266
Location
Philadelphia
I found some code for downloading the contents of a webpage, and it works great...in everything but XP SP2. For some reason it always throws an exception.
[CS]
public class CSDownloadURL
{
private string m_strURL;
public void setURL1( string strURL )
{
m_strURL = strURL;
}

public void DownloadURL(out string strContents)
{
WebRequest req = WebRequest.Create(m_strURL);
WebResponse res = req.GetResponse();
int iTotalBuff = 0;
Byte[] Buffer = new Byte[128];
Stream stream = res.GetResponseStream();
iTotalBuff = stream.Read(Buffer, 0, 128);
StringBuilder strRes = new StringBuilder("");

while(iTotalBuff != 0)
{
strRes.Append(Encoding.ASCII.GetString(Buffer, 0, iTotalBuff));
iTotalBuff = stream.Read(Buffer, 0, 128);
}

strContents = strRes.ToString();

}

}
[/CS]

Why would it work fine in everything but XP SP2 and windows 2003 server?
 
Any chance of saying what exception and where it occurs?
Also have you considered that the XP firewall may be causing problems connecting?
 
PlausiblyDamp said:
Any chance of saying what exception and where it occurs?
Also have you considered that the XP firewall may be causing problems connecting?

The exception occurs when I ask it to download the source to a webpage, here is the exception text (I am unsure of which line as it does not error on my SP1 machine[development machine])

System.Net.WebException: The underlying connection was closed: The server
committed an HTTP protocol violation.
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.HttpWebRequest.GetResponse()
at webdownload.CSDownloadURL.DownloadURL(String& strContents)
at webdownload.Form1.button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)


Any ideas? I am definately going to check out firewall issue in SP2 though, great idea!
 

Similar threads

E
Replies
0
Views
128
elfenliedtopfan55
E
D
Replies
0
Views
175
David William Smith
D
W
Replies
0
Views
95
want 2 Learn
W
Back
Top