I am using MachineKey API to encrypt/decrypt a piece of information in an ASP.NET application. I am using
MachineKey.Encode(data, MachineKeyProtection.All)
and
MachineKey.Decode(data, MachineKeyProtection.All)
methods of API. Everything works great on Windows 8 and Windows Server 2012 when Load User Profile is enabled. The problem is for some reason it doesn't survive app pool restart on Windows Server 2008 R2 with IIS 7.5
.
Initially I had impression that I will need to enable Load User Profile setting on Application Pool but that doesn't make any difference. Any idea what I could be missing here?
Thanks
Recycling means that the worker process that handles requests for that application pool is terminated and a new one is started. This is generally done to avoid unstable states that can lead to application crashes, hangs, or memory leaks.
As an aside you should schedule any application pool recycles to occur during off-peak hours, as you've realised it will clear any active sessions and will break the user experience if the application relies on session storage.
Cause: Application pools are configured to recycle when memory limits are exceeded. Resolution: Change the application pool recycling settings in Internet Information Services (IIS).
It could be that a new machine key is being generated by IIS each time the Application Pool recycles. Try setting a static machine key in your web.config as described here: IIS 7 Tip #10 You can generate machine keys from the IIS manager. Without explicitly setting a static machine key, your encryption/decryption key is a moving target.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With