[英]wcf service method caching not working
I am trying to implement caching in WCF service. 我正在尝试在WCF服务中实现缓存。 Please find the below code.
请找到下面的代码。
Contract : 合同:
[WebGet(UriTemplate = "")]
[OperationContract]
int GetNumber();
Contract implementation : 合同执行:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service1 : IService1
{
[AspNetCacheProfile("MoviesCollection")]
[WebGet(UriTemplate = "")]
public int GetNumber()
{
Random number = new Random();
return number.Next(1, 899);
}
}
Web.Config Web.Config中
<caching>
<outputCache enableOutputCache="true"/>
<outputCacheSettings>
<outputCacheProfiles>
<add name="MoviesCollection" location="Server" duration="6000" varyByParam="none"
enabled="true"/>
</outputCacheProfiles>
</outputCacheSettings>
</caching>
I am using WCF service application and not WCF service library. 我正在使用WCF服务应用程序,而不是WCF服务库。 Please let me know what i am missing here.
请让我知道我在这里想念的东西。 thanks.
谢谢。
Regards, Jebli 问候,吉卜力
“要启用WEB HTTP服务缓存,必须首先启用ASP.NET兼容性”。从MSDN中检查此链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.