How to manage cache in ASP.NET WebApi2?

后端 未结 3 937
忘了有多久
忘了有多久 2021-01-12 09:20

I have implemented REST service using WebAPI2, service implemeted to manage different sessions which are created and joined by different clients which are accessing service.

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-12 09:50

    @ScottHanselman said about a bug in .NET 4 here. I hope this fix help you:

    The temporary fix:

    Create memory cache instance under disabled execution context flow

    using (ExecutionContext.SuppressFlow())     {
              // Create memory cache instance under disabled execution context flow
             return new YourCacheThing.GeneralMemoryCache(…);
    }
    

    The Hotfix is http://support.microsoft.com/kb/2828843 and you can request it here: https://support.microsoft.com/contactus/emailcontact.aspx?scid=sw;%5BLN%5D;1422

提交回复
热议问题