title: Web API runs on Visual Studio but not when deployed on IIS
body: <p>I'm doing some research on integration with CIDR/Aadhaar systems (Indian system for unique identification of individuals). I chose the Nuget package which was the only available option that I found. The package data is present <a href="http://souvikdc9.github.io/aadhaarapi.net/" rel="nofollow noreferrer">here</a>.</p>
  
  <p>I developed a console application to test the code and I got successful results for the test data provided by <a href="https://authportal.uidai.gov.in/web/uidai/developer" rel="nofollow noreferrer">CIDR</a>. I then proceeded to develop a Web API 2 for the same and it worked perfectly the same way when I ran the project from Visual Studio (which uses IIS Express). But after deploying it to IIS, I get the following exception (I had downloaded the source of the package from Nuget to pinpoint the cause):</p>
  
  <pre><code>[2017-02-07 11:52:44:434]  http://localhost/AadhaarAPI/api/Aadhaar : Type : System.AggregateException
  [2017-02-07 11:52:44:434]  http://localhost/AadhaarAPI/api/Aadhaar : Error : One or more errors occurred.
  [2017-02-07 11:52:44:520]  http://localhost/AadhaarAPI/api/Aadhaar : Stacktrace :    
     at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
     at Uidai.Aadhaar.Agency.ApiClient`2.&lt;GetResponseXmlAsync&gt;d__25.MoveNext() in D:\Sujeet\VSProjects\AadhaarAPI\Uidai.Aadhaar\Agency\ApiClient.cs:line 138
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
     at Uidai.Aadhaar.Agency.ApiClient`2.&lt;GetResponseAsync&gt;d__22.MoveNext() in D:\Sujeet\VSProjects\AadhaarAPI\Uidai.Aadhaar\Agency\ApiClient.cs:line 94
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
     at Uidai.Aadhaar.Agency.ApiClient`2.&lt;GetResponseAsync&gt;d__21.MoveNext() in D:\Sujeet\VSProjects\AadhaarAPI\Uidai.Aadhaar\Agency\ApiClient.cs:line 78
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
     at AadhaarAPI.Controllers.AadhaarController.&lt;AuthenticateAsync&gt;d__13.MoveNext() in D:\Sujeet\VSProjects\AadhaarAPI\AadhaarAPI\Controllers\AadhaarController.cs:line 119
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
     at AadhaarAPI.Controllers.AadhaarController.CheckIfAadhaarIsValid(PersonalInfo personalInfo) in D:\Sujeet\VSProjects\AadhaarAPI\AadhaarAPI\Controllers\AadhaarController.cs:line 53
  </code></pre>
  
  <p>From my understanding so far, the await/async calls are the ones causing the error. The code snippet for the async call is as follows:</p>
  
  <pre class="lang-cs prettyprint-override"><code>var apiClient = new AuthClient
  {
      AgencyInfo = APIConfiguration.AgencyInfo,
      Request = new AuthRequest(deviceContext) { Signer = Signer },
      Response = new AuthResponse { Verifier = Verifier }
  };
  
  await apiClient.GetResponseAsync(); // This is where the call throws an error
  
  var response =  string.IsNullOrEmpty(apiClient.Response.ErrorCode)
              ? $"{apiClient.Response.IsAuthentic}"
              : $"{apiClient.Response.ErrorCode}";
  </code></pre>
  
  <p>Can someone please help me with understanding this error?  </p>
  
  <p>Please let me know if any other information is needed. I'm using Visual Studio 2017 RC for my development, if that matters.     </p>
  
  <p><strong>Disclaimer</strong>: The code snippet is also provided by the package developer. I don't take credit for any of this development.</p>
  
  <p><strong>EDIT</strong>:
  As per the comments, the details of the AggregateException are as follows:</p>
  
  <p><a href="https://i.stack.imgur.com/iWGXv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iWGXv.jpg" alt="enter image description here"></a></p>