title: WCF - An error occurred while receiving the HTTP response to http://xxxxx/Service/
body: <p>I am making this call in my WCF service:</p>
  
  <pre><code>public User GetStudentRecord(string userName)
      {
          try
          {
              return new DashboardFacade().GetStudentRecord(userName);
          }
          catch (Exception ex)
          {
              ServiceFault fault = new ServiceFault();
              fault.Operation = "GetStudentRecord";
              fault.Reason = "Who knows...";
              fault.Message = ex.Message;
              throw new FaultException&lt;ServiceFault&gt;(fault, fault.Message, new FaultCode(fault.Reason), fault.Operation);
          }
      }
  </code></pre>
  
  <p>DashboardFacade().GetStudentRecord(..) is defined like this:</p>
  
  <pre><code>public User GetStudentRecord(string userName)
  {
      User user = ctx.Users.Where(x =&gt; x.ADUserName == userName).SingleOrDefault();
      return user;
  }
  </code></pre>
  
  <p>ctx is my DbContext. I am using Entity Framework Code First. The User object looks like this:</p>
  
  <pre><code>public class User
  {
      public User()
      {
          //UserDetails = new UserDetail();
      }
      [Key]
      public Guid MasterKey { get; set; }
      public string FirstName { get; set; }
      public string LastName { get; set; }
      public string Email { get; set; }
      public string ADUserName { get; set; }
      public string UserType { get; set; }
      public virtual UserDetail UserDetails { get; set; }
      public Nullable&lt;DateTime&gt; LastModifiedDate { get; set; }
  }
  </code></pre>
  
  <p>And finally, you probably need to see the web.config on the WCF Application:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
      &lt;configuration&gt;
        &lt;connectionStrings&gt;
          &lt;add name="NotMyDBContextDB" connectionString="[omitted]" providerName="System.Data.SqlClient"/&gt;
          &lt;add name="ApplicationContext" connectionString="Data Source=.;Initial Catalog=MyApp;Integrated Security=True;Pooling=False" providerName="System.Data.SqlClient"/&gt;
        &lt;/connectionStrings&gt;
     &lt;system.web&gt;
       &lt;compilation debug="true" targetFramework="4.0"/&gt;
     &lt;/system.web&gt;
     &lt;system.serviceModel&gt;
       &lt;behaviors&gt;
         &lt;serviceBehaviors&gt;
            &lt;behavior&gt;
               &lt;serviceMetadata httpGetEnabled="true"/&gt;
               &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt;
            &lt;/behavior&gt;
          &lt;/serviceBehaviors&gt;
        &lt;/behaviors&gt;
        &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true"/&gt;
    &lt;/system.serviceModel&gt;
  &lt;system.webServer&gt;
  &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
  &lt;directoryBrowse enabled="true"/&gt;
  &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Can anyone point me to where I am going wrong here?</p>
  
  <p>This is the exact error I am getting:</p>
  
  <pre><code>An error occurred while receiving the HTTP response to http://localhost:5843/MyService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
  
  Inner Exception:
  The underlying connection was closed: An unexpected error occurred on a receive.
  
  Inner Exception:
  Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
  
  Inner Exception:
  An existing connection was forcibly closed by the remote host
  </code></pre>