469,267 Members | 922 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,267 developers. It's quick & easy.

WebClient error

yyy
This problem bothers me for a long time:
I use WebClient.DownloadData in order to read text from an HTML
document this way:

WebClient c = new WebClient();
string html=
ASCIIEncoding.Default.GetString(c.DownloadData("ht tp://www.test.com"));

When I run the code, I get this error message after a few seconds:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Net.WebException: The underlying connection was closed: Unable to connect to the remote server. at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncRes ult asyncResult) at System.Net.HttpWebRequest.GetResponse()
at System.Net.WebClient.DownloadData(String address)
at RE.MainForm.Button1Click(Object sender, EventArgs e) in c:\Documents and Settings\Y\My Documents\SharpDevelop
Projects\RE\MainForm.cs:line 93 at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs 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(M essage& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32

msg, IntPtr wparam, IntPtr lparam)

What can I do to solve it? It worked once and stopped working a few
months ago.
*---------------------------------*
Posted at: http://www.GroupSrv.com
*---------------------------------*

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 16 '05 #1
1 2817
I met the same error when the web site return 500 error.
Try to access the HTML document with ie, hope this be helpful.

"yyy" wrote:
This problem bothers me for a long time:
I use WebClient.DownloadData in order to read text from an HTML
document this way:

WebClient c = new WebClient();
string html=
ASCIIEncoding.Default.GetString(c.DownloadData("ht tp://www.test.com"));

When I run the code, I get this error message after a few seconds:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Net.WebException: The underlying connection was closed:

Unable to connect to the remote server.
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncRes ult

asyncResult)
at System.Net.HttpWebRequest.GetResponse()
at System.Net.WebClient.DownloadData(String address)
at RE.MainForm.Button1Click(Object sender, EventArgs e) in

c:\Documents and Settings\Y\My Documents\SharpDevelop
Projects\RE\MainForm.cs:line 93
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs 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(M essage&

m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32

msg, IntPtr wparam, IntPtr lparam)

What can I do to solve it? It worked once and stopped working a few
months ago.
*---------------------------------*
Posted at: http://www.GroupSrv.com
*---------------------------------*

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Justin Malloy | last post: by
2 posts views Thread by Max Gattringer | last post: by
reply views Thread by Kumar | last post: by
6 posts views Thread by Giovanni | last post: by
6 posts views Thread by =?Utf-8?B?U2NvdHQgVHJpY2s=?= | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.