从移动应用程序调用时,WCF缓存不起作用

我已经使用以下代码实现了WCF缓存:

iService.vb

<OperationContract()>
<AspNetCacheProfile("CacheFor60Seconds")>
<WebGet(RequestFormat:=Webmessageformat.Json,UriTemplate:="some-url?id={id}",BodyStyle:=WebMessageBodyStyle.Bare,ResponseFormat:=Webmessageformat.Json)>


Web.Config

<system.web>
    <caching>
      <outputCache enableOutputCache="true"></outputCache>
      <outputCacheSettings>
        <outputCacheProfiles>
          <add name="CacheFor60Seconds" duration="60" varyByParam="id"/>
        </outputCacheProfiles>
      </outputCacheSettings>
    </caching>
</system.web>

<system.serviceModel>
    <servicehostingEnvironment aspNetCompatibilityEnabled="true" minFreeMemoryPercentageToactivateService="0" multipleSiteBindingsEnabled="true">
    </servicehostingEnvironment>
</system.serviceModel>

当我使用浏览器调用REST API时,该解决方案可以正常工作。响应被缓存。但是,当我从移动应用程序调用REST API时,响应不会被缓存。我在这里想念任何东西吗?

zhu_yun_yun 回答:从移动应用程序调用时,WCF缓存不起作用

事实证明,由于某种原因,我不得不在Web.config中包含另一个参数,该参数已在移动移动应用程序中使用/从中调用:

<add name="CacheFor60Seconds" duration="60" varyByParam="id;param2"/>
本文链接:https://www.f2er.com/3127113.html

大家都在问