Validation of ViewState Mac failed exception
生活随笔
收集整理的這篇文章主要介紹了
Validation of ViewState Mac failed exception
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
Asp.net 的ViewState機(jī)制給我們帶來了很多方便,但是有時(shí)候也會(huì)產(chǎn)生一些莫名其妙的問題。很經(jīng)常遇到的就是ViewStae的驗(yàn)證出錯(cuò),以前就有遇到這樣的問題了。解決辦法都是把出現(xiàn)錯(cuò)誤的那個(gè)頁面的EnableViewStateMac屬性設(shè)置為"false",或者干脆就在web.config里<system.web><pages>節(jié)點(diǎn)屬性里設(shè)置就OK了,反正也不出錯(cuò)了,也沒想會(huì)不會(huì)產(chǎn)生安全性問題。
??? 今天又遇到了類似的問題了,異常信息也是類似的(記不太清楚了,好像是有點(diǎn)不一樣)提示信息是這樣的:
Exception Details: System.Web.HttpException: 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.
??? 在記錄的中文日志是說:數(shù)據(jù)無法驗(yàn)證
????可是這回不一樣了,把EnableViewStateMac設(shè)為false,還不能解決問題,還會(huì)出現(xiàn)另一個(gè)異常提示:
The state information is invalid for this page and might be corrupted.?
??? 網(wǎng)上也搜出一堆這樣的問題,可是沒有更好的解釋了(就算有也看不懂)。想到是加密解密的問題,看到<pages>節(jié)點(diǎn)下還有一個(gè)viewStateEncryptionMode屬性,于是就把它設(shè)為
Never 。再一試,問題就解決了,不出錯(cuò)了。可是不出錯(cuò)了,也改了默認(rèn)配置了,也不加密了,也不驗(yàn)證了,那會(huì)不會(huì)產(chǎn)生新的,更嚴(yán)重的問題--------安全性問題?
??? 今天又遇到了類似的問題了,異常信息也是類似的(記不太清楚了,好像是有點(diǎn)不一樣)提示信息是這樣的:
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.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Web.HttpException: 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.
??? 在記錄的中文日志是說:數(shù)據(jù)無法驗(yàn)證
????可是這回不一樣了,把EnableViewStateMac設(shè)為false,還不能解決問題,還會(huì)出現(xiàn)另一個(gè)異常提示:
The state information is invalid for this page and might be corrupted.?
??? 網(wǎng)上也搜出一堆這樣的問題,可是沒有更好的解釋了(就算有也看不懂)。想到是加密解密的問題,看到<pages>節(jié)點(diǎn)下還有一個(gè)viewStateEncryptionMode屬性,于是就把它設(shè)為
Never 。再一試,問題就解決了,不出錯(cuò)了。可是不出錯(cuò)了,也改了默認(rèn)配置了,也不加密了,也不驗(yàn)證了,那會(huì)不會(huì)產(chǎn)生新的,更嚴(yán)重的問題--------安全性問題?
總結(jié)
以上是生活随笔為你收集整理的Validation of ViewState Mac failed exception的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: (转) ASP.NET 2.0:使用用户
- 下一篇: 怎样才能快速批量绑定MAC与IP地址(图