简体   繁体   中英

Errors appear after connecting to Exchange Web Services (EWS) in C#

First of all, sorry for my poor english... Let's see if I can summarize the problem, it is quite strange:

Before we start... I have 2 users inside my company's domain.

  • User1 --> Has a proxy configured
  • User2 --> NO proxy configured

You are only able to navigate if you have the company's proxy configured, otherwise it won't load any webpage

1 - I log on into my computer using User1 domain credentials

2 - First, I open Internet Explorer, and I can navegate to any webpage, everything works fine. (I keep the window opened)

3 - I have a C# aplication running on my computer, which connects to EWS and logs into the mailbox of User2 . The code looks like this:

ExchangeService serviceInstance = null;
serviceInstance = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
serviceInstance.DateTimePrecision = DateTimePrecision.Milliseconds;
serviceInstance.Credentials = new WebCredentials(user, pass, domain);
serviceInstance.AutodiscoverUrl(mailbox);

After I connect to the mailbox, I loop the messages for different purposes, everything works fine, and I close the aplication.

4 - I open the same IE window from step 1 (I didn't close it) and I try to load any other page, for example, https://google.com the page doesn't load and it shows me a certificate error:

Certificate error

If I click on 'Continue to this website', a firewall error appears.

Firewall error

5 - If I close the IE window and open a new window, something, I don't know what, seems to restart, and I can navigate again to any webpage.

I have explained this problem with the Internet Explorer case, but that's just to make it more visual. I have another aplications on this computer which need to make http calls, connect to webservices... And they sometimes fail because of this.

Does anybody know what is happening? How can I solve this? Any help is appreciated!

You could try defining the proxy in your code eg

// set up the proxy
WebProxy proxy = new WebProxy("valid-proxy", 8080);
proxy.Credentials = new
NetworkCredential("valid-user","valid-password","valid-domain");
service.WebProxy = proxy;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM