Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8265075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:40:25+00:00 2026-06-08T04:40:25+00:00

I am using WebClient to download some resource in following way: Stream stream; try

  • 0

I am using WebClient to download some resource in following way:

 Stream stream;
 try
 {
  WebClient webClient = new webClient();
  stream = webClient.OpenRead(MyResourceUri);
 }
 catch (Exception)
 {
  return null;
 }
 return stream;

When I do this in a WPF application, it works fine and proper stream is obtained.

When I do this in a WCF service call, it doesn’t work. A WebException is thrown with message "Unable to connect to remote server". (It works for files hosted on my machine or within company network, however it fails for any resource on web). The service is hosted on IIS7.

Investigation so far reveals the difference is because of the webproxy. The webclient.proxy in WPF application refers to the proxy settings as set in IE, whereas the one in WCF is having none.

Why is it so? And more importantly, how can I make the WebClient in WCF use similar proxy settings?

EDIT: I set the proxy on WebClient and it worked in WCF service

webClient.Proxy = new WebProxy(ProxyAddressFromIE);

Here I have hardcoded the proxy addess. What method/APIs are there to obtain one? And still why its different in WCF service & in WPF application?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T04:40:28+00:00Added an answer on June 8, 2026 at 4:40 am

    To answer one of your questions, the reason there is a difference between your WPF application and your IIS hosted WCF service is this.

    WPF applications run in an actual Windows session (your user session to be exact). This means there is a user profile loaded for that session and that session contains, amongst other things, the proxy settings as configured in IE.

    WCF services hosted in IIS do not run in a Windows session. They are run as a service and therefor do not have a Windows session (they actually run in session 0, but that’s just an implementatio detail). This means there is no proxy configuration.

    To reliably solve this, you could have your own configuration for a proxy, perhaps in web.config.
    Another option is to configure the proxy through netsh.exe.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the WebClient.DownloadString() method to download some data. I am using the
I was using a BackgroundWorker to download some web sites by calling WebClient.DownloadString inside
I'm using WebClient to download some text from a web-page, like this: WebClient wc
I've got some code which downloads some RSS feeds. I've been using WebClient or
The following call returns a result in WinXP but not on Win7: using (WebClient
I am using the WebClient class to post some data to a web form.
I need to be able to download some file from a regular site using
I'm using this to make a web request and download some data: public partial
I'm using WebClient.DownloadString(url) to download a web page, when a url a 404 web
I am using This code to download a file private WebClient client; client =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.