Uses for MachineKey in ASP.NET

时间秒杀一切 提交于 2019-12-17 18:38:28

问题


What different ways are Machine Keys useful in asp.net? I think the following are correct but thought there may be more.

  1. Multiple applications can use the same cookie
  2. Multiple servers can work with the same viewstate

回答1:


MachineKey is used for:

  • ViewState encryption and validation
  • Forms Authentication (or Federated Authentication) uses this key for signing the authentication ticket

Having a Web App installed on multiple servers requires same Machine Key configured on all of them in order for Load Balancing to work.

To see all details, please refer to: MSDN How To: Configure MachineKey in ASP.NET 2.0




回答2:


Machine key is also used to encrypt/decrypt the webresources.axd parameters.

Even on a single server the machine key should be configured, because any recycle of the app domain will generate a new key when it is set to auto. This causes the next postback just for pages rendered before the recycle, to cause a viewstate validation error, and also issues with the resources during that time.




回答3:


Encryption - very common.



来源:https://stackoverflow.com/questions/550210/uses-for-machinekey-in-asp-net

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