WCF缓存就像使用Web Services一样

时间:2010-05-09 10:32:19

标签: asp.net wcf caching web-services

有人知道WCF是否支持像Web Services一样的缓存,还是应该手动实现?

1 个答案:

答案 0 :(得分:0)

我认为您需要在WCF实现类中设置[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]属性,如

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public class MyService: IMyService
{
   public void SomeMethod()
   {
        HttpContext.Current.Cache["someKey"] = "someValue";
   }
}

有关详细信息,请参阅http://msdn.microsoft.com/en-us/library/system.servicemodel.activation.aspnetcompatibilityrequirementsmode.aspx