專案部署於 NLB 叢集,壓力測試出現:
[HttpException (0x80004005): Validation of viewstate MAC failed.
If this application is hosted by a Web Farm or cluster,
ensure that <machineKey> configuration specifies the same
validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.]
GridView 設定 DataKeyNames 觸發 ViewState 加密,在 </form> 前插入 __VIEWSTATEENCRYPTED 隱藏欄位<pages enableEventValidation="false" viewStateEncryptionMode="Never" />
關閉事件驗證與 ViewState 加密。注意:此舉降低安全性,需評估風險。後續將討論 Event Validation 與 ViewState Validation 的實質與適用場景。