Webclient Exception In Linqpad, Internet connection attempts go poopy |
![]() ![]() |
Webclient Exception In Linqpad, Internet connection attempts go poopy |
Jun 18 2009, 08:53 AM
Post
#1
|
|
|
|
I'm having some issues with LINQPad making connections to the Internet. I use a web proxy through ISA Server, and LINQPad is configured with the same settings used by IE. Every connection attempt gives the message, "Error: An exception occurred during a WebClient request". I was trying to download the samples for the book, "LINQ in Action" through Samples->Download more samples... when this happenned. Every other feature of LINQPad that connects to the Internet gives the same message.
I would have used the built-in Report Bug, but it fails as well. Other than that, you have a fine product here. |
|
|
|
Jun 18 2009, 04:13 PM
Post
#2
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 215 Joined: 15-February 08 From: Perth, Australia Member No.: 90 |
Hi there
LINQPad uses the standard WebProxy class, which it populates using the web proxy details that you enter. (Go to Help | Check for Updates, and click Specify Web Proxy). Here's the code it uses to configure the WebClient object: CODE public WebClient GetWebClient () { System.Net.ServicePointManager.Expect100Continue = !DisableExpect100Continue; var wc = new WebClient (); if ((Address ?? "").Trim ().Length == 0) return wc; string a = Address.Trim (); if (Port > 0) a += ":" + Port; var proxy = new WebProxy { Address = new Uri (a) }; if ((Username ?? "").Trim ().Length > 0) { if ((Domain ?? "").Trim ().Length > 0) proxy.Credentials = new NetworkCredential (Username.Trim (), Password, Domain.Trim ()); else proxy.Credentials = new NetworkCredential (Username.Trim (), Password); } wc.Proxy = proxy; return wc; } If you're about to use the WebClient class yourself and I've done anything wrong here, please let me know! Joe |
|
|
|
Jun 18 2009, 06:10 PM
Post
#3
|
|
|
|
Hi there LINQPad uses the standard WebProxy class, which it populates using the web proxy details that you enter. (Go to Help | Check for Updates, and click Specify Web Proxy). Here's the code it uses to configure the WebClient object: Snipped for brevity by Buck. If you're about to use the WebClient class yourself and I've done anything wrong here, please let me know! Joe Hiya, Joe. Thanks for the code. I'll definitely give this a try. This also jump-started my memory, and a co-worker had a similar issue with using credentials in some VB.NET code for an ASP.NET project. I'll ask him what he did to get his code to work. Stay tuned... --Buck |
|
|
|
Jun 22 2009, 12:42 PM
Post
#4
|
|
|
|
Using your code, I figured out that the Address is supposed to be a proper URI. I left out the "http://" before. Works like a champ, now. Thanks again for the help.
|
|
|
|
Jun 24 2009, 03:33 AM
Post
#5
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 215 Joined: 15-February 08 From: Perth, Australia Member No.: 90 |
Terrific!
Thanks for letting me know. Joe |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 22nd November 2009 - 04:50 PM |