Search code examples
asp.net-mvc-4iisappfabric

Can't get cache when security protection level is set to unsafe


I'm testing the AppFabric cache feature in my website deployed from ASP.net MVC 4. In the web.config of my website, if I set the security level to anything except no security (None/None), like this

<securityProperties mode="Transport" protectionLevel="EncryptAndSign" />

then, getting cache from the method below will throw exception,

DataCacheFactory.GetDefaultCache()

Also, in the PowerShell Cache Management, I've already set the protection level to the same level (Transport/EncryptAndSign). But getting cache still failed.

Exception message is as following,

ErrorCode(ERRCA0017):SubStatus(ES0006):There is a temporary failure. Please retry later. (One or more specified cache servers are unavailable... )

The situation only happens in my deployed website. But if I run my website in Visual Studio debug mode, cache would response successfully no matter what the security level is set to.


Solution

  • OK! I finally solved the tricky issue. This tough thing nearly made me contribute my 50 bounties (almost half) !

    After some survey, I found the first clue,

    Security Error in APPFabric when changed the security mode from None to Transport?

    (Note, I can't easily google it out from some keywords, but the result I want was easily dug out from Msdn AppFabric Cache forum. I thought google search can help me to find any answer.)

    I got the same exception message as the first link. But Rahul's answer didn't work. However, Rahul's link revealed a second clue, that is, use Tracelog.exe to track the connection problem.

    From the track log in Event Viewer, I found there are some error events saying my server's authority isn't accessible, so I searched in the third clue, Cache Administration PowerShell commands for setting permission in PowerShell.

    In the third clue, thank the author, mark_og who really saved me ! You taught us how to set the permission in IIS like this,

    Grant-CacheAllowedClientAccount "IIS APPPOOL\[AppPoolName]"

    it's the key answer which solves my problem !