code_junkie

System.Net's Webclient in C# won't connect to server

Nov 13th, 2011
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3. using System.Windows.Forms;
  4. using System.IO;
  5. using System.Net;
  6.  
  7. namespace WindowsFormsApplication1
  8. {
  9. public partial class Form1 : Form
  10. {
  11. public Form1()
  12. {
  13. InitializeComponent();
  14.  
  15. using (WebClient client = new WebClient()) {
  16. string s = client.DownloadString("http://www.google.com");
  17. this.textBox1.Text = s;
  18. }
  19. }
  20. }
  21. }
  22.  
  23. Updated proxy settings
  24. Current WinHTTP proxy settings under:
  25. HKEY_LOCAL_MACHINE
  26. SOFTWAREMicrosoftWindowsCurrentVersionInternet SettingsConnections
  27. WinHttpSettings :
  28.  
  29. Direct access (no proxy server).
  30.  
  31. using (WebClient client = new WebClient()) {
  32. string s = client.DownloadString("http://www.google.com");
  33. // do something with s
  34. }
Add Comment
Please, Sign In to add comment