I am working on a WCF webHttpBinding web service a that passes realtime data back to a display board and the problem I am having is that the data from the database appears to be being cached.
I am developing the application using .Net4.5 and IISExpress 7.
I have the the enableOutputCache value to false and the aspNetCompatibilityEnabled value to false but the data returned is still cached.
Config File
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<caching>
<outputCache enableOutputCache="false"/>
</caching>
</system.web>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<connectionStrings>
<add name="JcbManufacturingPortalEntities" connectionString="metadata=res://*/xxxxx.csdl|res://*xxxxx.ssdl|res://*/xxxxx.msl;provider=System.Data.SqlClient;provider connection string="data source=xxxxx;initial catalog=xxxxx;persist security info=True;user id=xxxxx;password=xxxxx;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<system.serviceModel>
<services>
<service behaviorConfiguration="AndonRest" name="Jmp.Andon.Service.AndonService">
<endpoint binding="webHttpBinding" bindingConfiguration="RestBinding" name="Jmp.Andon.Service.AndonService" contract="Jmp.Andon.Service.IAndonService" behaviorConfiguration="webBehaviour" />
<host>
<baseAddresses>
<add baseAddress="https://localhost:44302/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webBehaviour">
<dataContractSerializer maxItemsInObjectGraph="655360" />
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="AndonRest">
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />
<bindings>
<webHttpBinding>
<binding name="RestBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="Transport" />
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
The underlying problem was that I was using a single cached DBContext for each call instance.
In order to prevent the DB context caching the data I implemented the AsNoTracking extension from the
System.Data.Entity
dll.