title: Why getting System.Net.Http.HttpRequestException when run my application in windows 7
body: <p>I am develop a WPF application which can communicate my server using Http Client. </p>
  
  <p>My Application build on .NET 4. I install Http Client via nugget. I also install 
  <strong>Microsoft.CompilerServices.AsyncTargetingPack</strong> via nugget. </p>
  
  <p>In Windows 8 it works without any problem. But in Windows 7 I get an Exception</p>
  
  <blockquote>
    <p>Application: whost.Generator.Creator.exe Framework Version: v4.0.30319
    Description: The process was terminated due to an unhandled exception.
    Exception Info: System.Net.Http.HttpRequestException Stack:</p>
    
    <p>Server stack trace:</p>
    
    <p>Exception rethrown at [0]:     at
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
    task)    at
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task
    task)    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at
    whost.Generator.Creator.Basic.ServerCommunicator.d__10.MoveNext()</p>
    
    <p>Exception rethrown at [1]:     at
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
    task)    at
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task
    task)    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at
    whost.Generator.Creator.ViewModel.LicenseGenerateViewModel.d_<em>3.MoveNext()
    at
    System.Runtime.CompilerServices.AsyncMethodBuilderCore.b</em>_0(System.Object)
    at
    System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate,
    System.Object, Int32)    at
    MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object,
    System.Delegate, System.Object, Int32, System.Delegate)    at
    System.Windows.Threading.DispatcherOperation.InvokeImpl()    at
    System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
    at System.Threading.ExecutionContext.runTryCode(System.Object)    at
    System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode,
    CleanupCode, System.Object)    at
    System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext,
    System.Threading.ContextCallback, System.Object)    at
    System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,
    System.Threading.ContextCallback, System.Object, Boolean)    at
    System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,
    System.Threading.ContextCallback, System.Object)    at
    System.Windows.Threading.DispatcherOperation.Invoke()    at
    System.Windows.Threading.Dispatcher.ProcessQueue()    at
    System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr,
    IntPtr, Boolean ByRef)    at MS.Win32.HwndWrapper.WndProc(IntPtr,
    Int32, IntPtr, IntPtr, Boolean ByRef)    at
    MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)    at
    System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate,
    System.Object, Int32)    at
    MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object,
    System.Delegate, System.Object, Int32, System.Delegate)    at
    System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority,
    System.TimeSpan, System.Delegate, System.Object, Int32)    at
    MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)<br>
    at
    MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG
    ByRef)    at
    System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
    at
    System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
    at System.Windows.Threading.Dispatcher.Run()    at
    System.Windows.Application.RunDispatcher(System.Object)    at
    System.Windows.Application.RunInternal(System.Windows.Window)    at
    System.Windows.Application.Run(System.Windows.Window)    at
    System.Windows.Application.Run()    at
    whost.Generator.Creator.App.Main()</p>
  </blockquote>
  
  <p>I don`t understand why I get this exception.
  My Server is build on MVC 4 And WEB API.</p>
  
  <p>Thanks in advance.  </p>
  
  <p>Update 1: 
         My Code Is:</p>
  
  <pre><code>    var handler = new HttpClientHandler();
      var cookieContainer = new CookieContainer();
      handler.CookieContainer = cookieContainer;
      var client = new HttpClient(handler) { BaseAddress = new Uri("http://myhost.com/") };
      client.DefaultRequestHeaders.Accept.Add(
      new MediaTypeWithQualityHeaderValue("application/json"));
      var loginModel = new LoginModel
         {
           UserName = Username,
           Password = Password,
         };
      var userLoginResposnce = await client.PostAsJsonAsync("account/Login", loginModel);
      var successInfoTamplate = new { Success = true };
      var loginResponceString = await userLoginResposnce.Content.ReadAsStringAsync();
      var isSuccess = JsonConvert.DeserializeAnonymousType(loginResponceString, successInfoTamplate);
  </code></pre>
  
  <p>I installed .NET 4 On My Windows 7 PC.</p>