자료/ASP.NET

ViewSate Mac 검사 오류

네오블루 2009. 6. 19. 20:32

서버 폼을 포함한 ASP.NET 페이지에서 다른 페이지로 전송할 때가 있다.

form.aspx

-------------------------------------------------------------------

<form id="sampleForm" runat="server" action="proc.aspx" method="post">...</form>
-------------------------------------------------------------------------------

이와 같이 실행하게 되면 proc.aspx 페이지에서 다음과 같은 오류를 만나게 된다.

Server Error in ‘/’ Application.
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.

아직은 .NET Framework를 많이 사용해보지 못해서 그런지 당황스러울 때가 있다.

단일 서버를 사용 중인데 이와 같은 오류 메시지는 더욱 그러하다.

이런 오류를 해결하기 위해서는 데이터를 받는 페이지에서는 ViewState Mac을 검사하지 않도록 해주면 된다.

proc.aspx

-------------------------------------------------------------------------

%@Page Language="C#" EnableViewStateMac="false" %
-------------------------------------------------------------------------------------

물론 web.config 파일에서 <pages enableViewStateMac=”false”/> 와 지정할 수도 있다.

자료

출처 :http://www.barney.pe.kr/blog/926