简体   繁体   中英

how to solve “Validation of viewstate MAC failed” error while using form in ASP.NET?

I'm trying to use a post method in a form using asp and C# , but Validation of viewstate MAC failed error happens here is my code :

<body>
  <div class="clearfix">
    <label>User Name : </label>
    <input id="u" runat="server"/>
  </div>
  <div class="clearfix">
    <label>Password : </label>
    <input id="p" runat="server" />
   </div>
   <asp:Button runat="server" Text="Enter"/>
   <label id="notificationLabel" />
</body>

i tried both adding machin key to web config that didnt work . just like this :

<machinekey validation="SHA1" validationkey="A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1B2C3D4E5" decryption="Auto" decryptionkey="A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1" />

also in admin.aspx page i added these but still not working :

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="admin.aspx.cs" Inherits="admin" EnableEventValidation="false" ViewStateEncryptionMode="Never" ViewStateMode="Disabled" EnableViewStateMac="false" EnableViewState="false" %>

just add :

  <pages enableViewStateMac="false" />

in the web config file .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM