When creating a webrequest in c#, how do I get the appropriate proxy information?

I want to create a webrequest with the current proxy information.  I've tried several routines to get the current proxy information but I'm not getting what I expected.  

On this machine I have my connection proxy set to "No Proxy" (Firefox - Tools/Options/connection settings).  I do have data in the "Manual Proxy Configuration", but with the "No Proxy" option selected the manual proxy information is grayed out.  I would expect in this configuration for the proxy to be null.  However, when I use GetSystemWebProxy or similar functions it is returning the manual proxy information, not null as I would expect.  What is the proper "GetTheProxy()" routine in the example below?

Example Code:

 public HttpWebRequest GetWebRequest(string url)
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
            IWebProxy theProxy = GetTheProxy();
            req.Proxy = theProxy;
            req.Timeout = 10000;
            return req;

public iWebProxy GetTheProxy()
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Todd GerbertIT ConsultantCommented:
I'm not 100% certain, but I would expect that the decision whether to use a proxy or not is application-specific - meaning that your FireFox settings really only apply to FireFox (plus the Microsoft docs say specifically that GetSystemWebProxy returns Internet Explorer's settings - http://msdn.microsoft.com/en-us/library/system.net.webrequest.getsystemwebproxy.aspx)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cre8nAuthor Commented:
Thanks tgerbert.  I didn't realize the I would need to change the connection properties in both, IE and FF and I still had the proxy configured for IE.  I assumed that both would use the same connection properties.  I changed IE and it worked as expected.

Todd GerbertIT ConsultantCommented:
If it makes sense, you might consider a configuration screen allowing the user to set proxy parameters, and just have it default to what's returned by GetSystemWebProxy.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.