Machine Key changes when app pool is recycled

南楼画角 提交于 2019-12-01 02:14:16

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.

Tamas

@pstricker is right, if there's no machine key defined, then on app pool startup a new key is generated. MachineKey API is based on the machine key, so it needs to be set somewhere. If you don't want to set the machineKey in the application's web config, you can still do it in the server's machine config, here: "C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config"

Also, if you want a per app pool machine key, you can do what's described here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!