I am using the EWS Managed API 1.2 in my C# .NET 3.5 Web application.
I have an exchange user which can impersonate the user logged into my application to create/update their calendar items on exchange.
The issue is that upon initial creation of this ExchangeService object I have to wait 24 seconds. This wait is unacceptably long if it happens upon each action so my solution is to store the ExchangeService object inside the session. This still has the initial overhead of 24 seconds for each user which is OK but I feel like I am trying to solve this incorrectly. Is there a standard way to instantiate this? For example on application start and then the one object is used by multiple people? Or a standard place to put an instance of the ExchangeService object? I can’t seem to find examples of this kind of use in an application – all the examples I see show the instantiation happen in each request which would make for many very lengthy requests!
I also thought it may be possible to create it in another thread however the thread could not access the session that created it.
EDIT #2
See my answer below.
I have resolved my problem.
Incase anyone else is a foolish as me, my issue was that for each creation I was using this:
service.AutodiscoverUrl("user@domain.com");Once you have done the initial auto discover, you should use the address of the exchange service found in that call. Then you can just set the URL to that, foregoing the autodiscover call.