title: Web service returns "Access is denied" for only some requests
body: <p>I have an ASP.NET in C# web application which consumes data from a web service. It works                 just fine most of the time, but sometimes, usually when requesting larger data sets, it         only returns an Access is denied error.</p>
  
  <p>For instance, if I call the service to return some documents from between a certain date range, with a small enough range it works just fine. If I expand the range too far, however, it returns this error. This leads me to believe it's either a size or a time issue.</p>
  
  <p>However, if I try to return all of the documents it returns the Access is denied error almost instantly, with no waiting.</p>
  
  <p>I'm pretty certain the problem lies between the service and the app, or even in the configuration of the app.</p>
  
  <p>Can anyone help me discover why I am getting this vague Access is denied error? Let me know if there's more information I should supply.</p>
  
  <p><strong>Edit:</strong>
  I do control the web service. </p>
  
  <p>I've tried calling the service through a little windows form app and I've never seen any errors.</p>
  
  <p>I'm calling the web service via some kind of contract client? I'm not sure of the specifics, but I just have a service reference pointing to the service, and then I am able to declare a client and then use the methods within.</p>
  
  <p>I am able to access the service just fine in the browser.</p>
  
  <p>As far as the other questions go, I'm not sure yet. I'll look into it further.</p>
  
  <p><strong>Edit 2:</strong>
  Here's the config for the Client:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;connectionStrings&gt;
      //omitted
    &lt;/connectionStrings&gt;
    &lt;system.web&gt;
      &lt;httpRuntime executionTimeout="300" maxRequestLength="51200" /&gt;
  &lt;pages theme="Theme1" /&gt;
  &lt;compilation debug="true" targetFramework="4.0"&gt;
    &lt;assemblies&gt;
      //omitted 
    &lt;/assemblies&gt;
  &lt;/compilation&gt;
  &lt;authentication mode="Windows" /&gt;
  &lt;authorization&gt;
    &lt;deny users="?" /&gt;
  &lt;/authorization&gt;
  &lt;membership&gt;
    &lt;providers&gt;
      &lt;clear /&gt;
      &lt;add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /&gt;
    &lt;/providers&gt;
  &lt;/membership&gt;
  &lt;profile&gt;
    &lt;providers&gt;
      &lt;clear /&gt;
      &lt;add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" /&gt;
    &lt;/providers&gt;
  &lt;/profile&gt;
  &lt;roleManager enabled="false"&gt;
    &lt;providers&gt;
      &lt;clear /&gt;
      &lt;add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" /&gt;
      &lt;add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" /&gt;
    &lt;/providers&gt;
  &lt;/roleManager&gt;
  &lt;httpHandlers&gt;
      &lt;add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" /&gt;
  &lt;/httpHandlers&gt;
  &lt;/system.web&gt;
  &lt;system.webServer&gt;
  &lt;modules runAllManagedModulesForAllRequests="true" /&gt;
  &lt;validation validateIntegratedModeConfiguration="false" /&gt;
  &lt;handlers&gt;
    &lt;add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" /&gt;
  &lt;/handlers&gt;
  &lt;/system.webServer&gt;
  &lt;appSettings&gt;
  //omitted
  &lt;/appSettings&gt;
  &lt;system.serviceModel&gt;
      &lt;bindings&gt;
          &lt;basicHttpBinding&gt;
              &lt;binding name="DefaultEndpoint" closeTimeout="00:09:00" openTimeout="00:09:00" receiveTimeout="00:10:00" sendTimeout="00:09:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"&gt;
        &lt;readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
        &lt;security mode="TransportCredentialOnly"&gt;
          &lt;transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" /&gt;
          &lt;message clientCredentialType="UserName" algorithmSuite="Default" /&gt;
        &lt;/security&gt;
      &lt;/binding&gt;
      &lt;binding name="DefaultEndpoint1" closeTimeout="00:09:00" openTimeout="00:09:00" receiveTimeout="00:10:00" sendTimeout="00:09:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"&gt;
        &lt;readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
        &lt;security mode="TransportCredentialOnly"&gt;
          &lt;transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" /&gt;
          &lt;message clientCredentialType="UserName" algorithmSuite="Default" /&gt;
        &lt;/security&gt;
      &lt;/binding&gt;
    &lt;/basicHttpBinding&gt;
  &lt;/bindings&gt;
  &lt;client&gt;
    &lt;endpoint address="/*omitted*/ " binding="basicHttpBinding" behaviorConfiguration="ServiceBehavior" bindingConfiguration="DefaultEndpoint" contract="/*omitted*/ " name="DefaultEndpoint" /&gt;
    &lt;endpoint address="/*omitted*/ " binding="basicHttpBinding" behaviorConfiguration="ServiceBehavior" bindingConfiguration="DefaultEndpoint1" contract="/*omitted*/ " name="DefaultEndpoint1" /&gt;
  &lt;/client&gt;
  &lt;behaviors&gt;
    &lt;endpointBehaviors&gt;
      &lt;behavior name="ServiceBehavior"&gt;
        &lt;dataContractSerializer maxItemsInObjectGraph="2147483647" /&gt;
      &lt;/behavior&gt;
    &lt;/endpointBehaviors&gt;
  &lt;/behaviors&gt;
  &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>And here's the config for the service:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=/*omitted*/" &gt;
          &lt;section name="ITSLogger.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=/*omitted*/" requirePermission="false" /&gt;
      &lt;/sectionGroup&gt;
  &lt;/configSections&gt;
  &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.0" /&gt;
      &lt;authentication mode="Windows"&gt;&lt;/authentication&gt;
      &lt;!--&lt;anonymousIdentification enabled="false"/&gt;--&gt;
  &lt;/system.web&gt;
  &lt;system.serviceModel&gt;
  &lt;services&gt;
    &lt;service behaviorConfiguration="RWS.ServiceImplementation.ResearchService_Behavior"
      name="RWS.ServiceImplementation.ResearchService"&gt;
      &lt;endpoint address="" binding="basicHttpBinding" name="DefaultEndpoint"
        bindingNamespace="http://researchwebservice.model/research" bindingConfiguration="userHttp"
        contract="RWS.ServiceContracts.IResearchServiceContract"/&gt;
      &lt;!--&lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;--&gt;
    &lt;/service&gt;
  &lt;/services&gt;
  &lt;bindings&gt;
    &lt;basicHttpBinding&gt;
      &lt;binding name="userHttp"
               closeTimeout="00:01:00"
               openTimeout="00:01:00"
               receiveTimeout="00:10:00"
               sendTimeout="00:01:00"
               allowCookies="false"
               bypassProxyOnLocal="false"
               hostNameComparisonMode="StrongWildcard"
               maxBufferSize="2147483647"
               maxBufferPoolSize="2147483647"
               maxReceivedMessageSize="2147483647"
               messageEncoding="Text"
               textEncoding="utf-8"
               transferMode="Buffered"
               useDefaultWebProxy="true"&gt;
        &lt;readerQuotas maxDepth="2147483647"
                      maxStringContentLength="2147483647"
                      maxArrayLength="2147483647"
                      maxBytesPerRead="2147483647"
                      maxNameTableCharCount="2147483647" /&gt;
        &lt;security mode="TransportCredentialOnly"&gt;
          &lt;transport clientCredentialType="Ntlm" /&gt;
          &lt;message clientCredentialType="UserName"/&gt;
        &lt;/security&gt;
      &lt;/binding&gt;
  
    &lt;/basicHttpBinding&gt;
  &lt;/bindings&gt;
  &lt;behaviors&gt;
    &lt;serviceBehaviors&gt;
      &lt;behavior name=""&gt;
        &lt;serviceMetadata httpGetEnabled="false" /&gt;
        &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
        &lt;dataContractSerializer maxItemsInObjectGraph="2147483647"/&gt;
      &lt;/behavior&gt;
      &lt;behavior name="RWS.ServiceImplementation.ResearchService_Behavior"&gt;
        &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
        &lt;serviceMetadata httpGetEnabled="true" /&gt;
        &lt;dataContractSerializer maxItemsInObjectGraph="2147483647"/&gt;
      &lt;/behavior&gt;
    &lt;/serviceBehaviors&gt;
  &lt;/behaviors&gt;
  &lt;/system.serviceModel&gt;
  &lt;system.webServer&gt;
    &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
  &lt;/system.webServer&gt;
  &lt;connectionStrings&gt;
    &lt;add name="ITSLogger.Properties.Settings.ITSLoggerConnectionString"
          connectionString=/*omitted*/
          providerName="System.Data.SqlClient" /&gt;
  &lt;/connectionStrings&gt;
  
  &lt;applicationSettings&gt;
    &lt;ITSLogger.Properties.Settings&gt;
      &lt;setting name="LogFilePath" serializeAs="String"&gt;
        &lt;value&gt;C:\ITSLogger\LoggerTest\&lt;/value&gt;
      &lt;/setting&gt;
      &lt;setting name="MailServer" serializeAs="String"&gt;
      &lt;value&gt;/*omitted*/&lt;/value&gt;
    &lt;/setting&gt;
    &lt;setting name="MailRecipient" serializeAs="String"&gt;
      &lt;value&gt;sklingbeil@itsmtc.com&lt;/value&gt;
    &lt;/setting&gt;
    &lt;setting name="CanLogToEmail" serializeAs="String"&gt;
      &lt;value&gt;False&lt;/value&gt;
    &lt;/setting&gt;
    &lt;setting name="CanLogToFlatFile" serializeAs="String"&gt;
      &lt;value&gt;False&lt;/value&gt;
    &lt;/setting&gt;
    &lt;setting name="CanLogToTrace" serializeAs="String"&gt;
      &lt;value&gt;False&lt;/value&gt;
    &lt;/setting&gt;
    &lt;setting name="CanLogToConsole" serializeAs="String"&gt;
      &lt;value&gt;False&lt;/value&gt;
    &lt;/setting&gt;
    &lt;setting name="CanLogToEventLog" serializeAs="String"&gt;
      &lt;value&gt;true&lt;/value&gt;
    &lt;/setting&gt;
    &lt;setting name="CanLogToDB" serializeAs="String"&gt;
      &lt;value&gt;False&lt;/value&gt;
    &lt;/setting&gt;
  &lt;/ITSLogger.Properties.Settings&gt;
  &lt;/applicationSettings&gt;
  
  &lt;system.diagnostics&gt;
  &lt;sources&gt;
    &lt;source name="System.ServiceModel"
                  switchValue="Information, ActivityTracing"
                  propagateActivity="true"&gt;
      &lt;listeners&gt;
        &lt;add name="traceListener"
            type="System.Diagnostics.XmlWriterTraceListener"
            initializeData= "/*omitted*/" /&gt;
      &lt;/listeners&gt;
    &lt;/source&gt;
  &lt;/sources&gt;
  &lt;/system.diagnostics&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I've omitted a few things here and there that I thought might be too revealing.</p>