Mossy's World | Weird Stuff..

Oct/09

15

C# – Configure Proxy for Webclient

Snippet of code to configure a web proxy

private static readonly IWebProxy sDefaultProxy = WebRequest.DefaultWebProxy;

public string ProxyUser = “”;
public string ProxyPassword = “”;
public bool ProxyUse = false;
public bool ProxyDefault = true;
public string ProxyAddress = “”;
public int ProxyPort = 80;

public static void ProxyConfig()
{
if (Controller.Config.Default.ProxyUse)
{
NetworkCredential credential = null;
if ((Controller.Config.Default.ProxyUser.Length > 0) ||
(Controller.Config.Default.ProxyPassword.Length > 0))
{
credential = new NetworkCredential();
credential.UserName = Controller.Config.Default.ProxyUser;
credential.Password = Controller.Config.Default.ProxyPassword;
}
if (!Controller.Config.Default.ProxyDefault)
{
var proxy = new WebProxy(Controller.Config.Default.ProxyAddress, Controller.Config.Default.ProxyPort);
if (credential != null)
{
proxy.Credentials = credential;
}
WebRequest.DefaultWebProxy = proxy;
}
else if (credential != null)
{
WebRequest.DefaultWebProxy.Credentials = credential;
}
}
else
{
WebRequest.DefaultWebProxy = sDefaultProxy;
}
}

public static void ProxyConfig()

{

if (ProxyUse)

{

NetworkCredential credential = null;

if ((ProxyUser.Length > 0) ||

(ProxyPassword.Length > 0))

{

credential = new NetworkCredential();

credential.UserName = ProxyUser;

credential.Password = ProxyPassword;

}

if (!ProxyDefault)

{

var proxy = new WebProxy(ProxyAddress, .ProxyPort);

if (credential != null)

{

proxy.Credentials = credential;

}

WebRequest.DefaultWebProxy = proxy;

}

else if (credential != null)

{

WebRequest.DefaultWebProxy.Credentials = credential;

}

}

else

{

WebRequest.DefaultWebProxy = sDefaultProxy;

}

}

RSS Feed

46 Comments for C# – Configure Proxy for Webclient

fdahho | December 2, 2009 at 2:49 AM

wYjCPG ztfrvogfflwm, [url=http://xpezokhmijkf.com/]xpezokhmijkf[/url], [link=http://lfvriukvqror.com/]lfvriukvqror[/link], http://bhqsrpdrcfht.com/

jjiuev | January 12, 2010 at 8:30 PM

lrlAWe dzefefclsimj, [url=http://pzmkmmolsyvk.com/]pzmkmmolsyvk[/url], [link=http://jhcybugoxytn.com/]jhcybugoxytn[/link], http://xrijsxsehvuy.com/

bodybold1 | January 14, 2010 at 6:56 PM

viagra fcbsiz levitra 7853 accutane nutx auto insurance kzam

protected | January 16, 2010 at 3:55 AM

nexium dvsq viagra zatf accutane osy buy levitra 892 cialis wbw

mokuska2901 | January 17, 2010 at 10:42 AM

valium =-PP cialis 9918 ativan dnkxi generic viagra =-O cialis 092478

crash | January 22, 2010 at 10:20 PM

home insurance =-P health insurance yxycf auto insurance wwon auto insurance 8-D

bekezd | January 25, 2010 at 3:39 AM

home insurance 424583 cheap auto insurance :-] health insurance ddabxf

jscheuer1 | January 26, 2010 at 3:22 AM

homeowners insurance >:O home insurance >:-(( cheap auto insurance vnuuu auto insurance quotes 2848 auto insurance rates ywjz

transcriptlogobg | February 1, 2010 at 6:48 PM

life insurance =( cheap auto insurance 847807 car insurance quotes :-( ((

ludmila | February 2, 2010 at 9:27 PM

short term health insurance 63266 auto insurance quotes xpk auto insurance 082 auto insurance =OOO

ohfxxmpxp | February 3, 2010 at 5:49 AM

BoqaxP cysjgdnddlpp, [url=http://fsluytmmcvac.com/]fsluytmmcvac[/url], [link=http://jxscjtncttro.com/]jxscjtncttro[/link], http://yjvpwlowkgpo.com/

elizaveta | February 3, 2010 at 11:53 PM

supplemental health insurance nrc american life insurance wpiub health insurance 83250 auto insurance 412

terri | February 4, 2010 at 3:14 PM

home insurance 834 auto insurance 63872 health insurance online 9549 car insurance for woman 8[[

roland | February 5, 2010 at 10:14 PM

aciphex 20 mg 0179 lowest prices for tramadol online hjgky buy ambien =-OOO xanax =P phentermine aciphex phentermine cvs pharmacy miami 818

titel1 | February 6, 2010 at 1:59 AM

phentermine dicvtb xanax ufcv aciphex phentermine pharmacy jobs nkygr ultram dye

store | February 7, 2010 at 4:21 PM

tramadol :-D ultram :]]] propecia 8DD ultram >:( buy cialis 94848 buy cialis =-) viagra =-PP ultram 896894

formatvorlage3 | February 7, 2010 at 7:54 PM

buy levitra 886581 accutane 64092 xanax 342172 viagra propecia buy online %-PPP levitra =-) cialis bgv levitra viagra vs %-OOO

glycyrrhiza | February 8, 2010 at 9:17 PM

buy tramadol 420107 propecia 404005 life insurance pjk phentermine overnight 666248 car insurance quotes 5374 accutane 876637 auto insurance quotes :[

taisia | February 9, 2010 at 12:37 AM

accutane 8230 ultram vbqk levitra 27261 health insurance quotes %-))) tramadol 824277 accutane 8O

coloroffline | February 9, 2010 at 8:50 PM

life insurance 57763 buy tramadol ifo generic cialis cjz valium 8-PPP lowest prices for tramadol online 59856 ultram aiq aciphex phentermine pharmacy washington dc :-P PP

plexproject | February 10, 2010 at 3:43 AM

cialis 577020 propecia zyban celebrex acyclovir and vioxx >:((( valium >:-((( adderall aciphex zoloft heartburn %-D

tshering | February 10, 2010 at 3:54 AM

aciphex gsxa xanax without prescription =-) discount xanax 710479 phentermine without a prescription oqr accutane :P car insurance 9414 accutane 62259

tatiana | February 10, 2010 at 11:05 AM

plavix and aciphex =OO levitra gjpooh health insurance gee health insurance quotes 8(((

black | February 12, 2010 at 12:34 AM

online casinos xeg health insurance %-P florida auto insurance 0353 car insurance kybjeh

Pharmc283 | February 26, 2010 at 4:04 AM

Hello! gkddefk interesting gkddefk site!

Pharmf626 | February 26, 2010 at 4:04 AM

Very nice site! cheap viagra

Pharmk323 | February 26, 2010 at 4:04 AM

Very nice site! [url=http://oixapey.com/rqasss/2.html]cheap cialis[/url]

Pharme198 | February 26, 2010 at 4:04 AM

Very nice site! cheap cialis http://oixapey.com/rqasss/4.html

Pharme46 | February 26, 2010 at 4:05 AM

Very nice site!

Pharmk784 | February 26, 2010 at 4:05 AM

fromeLahweema | February 27, 2010 at 8:13 AM

dating flash game online prayer for youth dating sugar daddy dating http://loveepicentre.com/ plus size personals

phentermine | February 27, 2010 at 8:16 PM

cialis | February 28, 2010 at 9:18 PM

Hello!
cialis , xanax , viagra , viagra , xanax ,

gregory | March 3, 2010 at 11:13 PM

xiaoman | March 4, 2010 at 8:27 PM

xanax fwixba diet pill acomplia also called rimonaban ptnixb buy cheap aciphex online 762250 tramadol :) ))

gangzhu | March 4, 2010 at 11:33 PM

taking cialis and viagra together :-) ) ambien %[ retin a 603709 propecia uymwj

azadirachta | March 6, 2010 at 3:43 AM

cialis levitra viagra 8)) what does xanax look like zlwx buy phentermine :]]] buy tramadol wholesale ycctz propecia viagra rfot

katelyn | March 6, 2010 at 7:21 AM

prednisone oji generic valium diudjc buy acomplia rimonabant online =-((( doxycycline mrksfo

Pharmb573 | March 7, 2010 at 3:03 PM

Hello! cefdbag interesting cefdbag site!

Pharmk617 | March 7, 2010 at 3:03 PM

Very nice site! cheap viagra

Pharmf188 | March 7, 2010 at 3:03 PM

Very nice site! [url=http://apeoixy.com/tqastv/2.html]cheap cialis[/url]

Pharmg198 | March 7, 2010 at 3:03 PM

Very nice site! cheap cialis http://apeoixy.com/tqastv/4.html

Pharmc853 | March 7, 2010 at 3:03 PM

Very nice site!

Pharmb426 | March 7, 2010 at 3:04 PM

mustervorname | March 7, 2010 at 6:22 PM

phentermine 49895 buy cheap acomplia online =OOO aciphex phentermine alprazolam online pharmacy =[[ ultram grcrbw

dottedtr | March 7, 2010 at 9:46 PM

prednisone yxxk ambien >:-((( retin =PPP

Leave a comment!

« Ford KA – Stupid Engines!

C# – Easy Sockets Class »

Find it!

Theme Design by devolux.org

Tag Cloud