Even with ASP.NET 3.5, I am getting "Validation of viewstate MAC failed" error -


i found lost of posts solve error: "validation of viewstate mac failed". read asp.net 2.0 error bug. using vs 2008 asp.net 3.5 sp1. why error coming in version also?

i using asp textbox controls. posts have mentioned asp textboxes generate error, have set autopostback of each textbox false.

how rid of mess?

code added below **

* default.aspx *

<%@ page language="c#" autoeventwireup="true" codebehind="default.aspx.cs" inherits="flexstock._default" %>  <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">     <!--<%@ register assembly="mscaptcha" namespace="mscaptcha" tagprefix="cc1" %>-->     <link rel="stylesheet" type="text/css" href="~/styles/main.css" />     <title>flexstock@.net - gamma edition</title> </head> <body id="loginpagebody" class="loginpagebodyclass"> <img id="imgproductlogo" src="styles/stockist_gamma.png" style="text-align:center;text-shadow:black;margin-left:500px" alt="product logo"/>     <form id="loginform" runat="server" class="loginform" action="./forms/selectcompany.aspx" >     <div id="divmainloginpage" runat="server">         <div class="label">             <asp:label id="lblusername" runat="server" cssclass="labelcontrols" associatedcontrolid="txtusername">user name: </asp:label>              </div>          <div class="value">             <asp:textbox id="txtusername" runat="server" cssclass="txtstyle" width="199px" autopostback="false"></asp:textbox>         </div>          <div class="label">             <asp:label id="lblpassword" runat="server" cssclass="labelcontrols" associatedcontrolid="txtpassword">password: </asp:label>              </div>          <div class="value">             <asp:textbox id="txtpassword" runat="server" cssclass="txtstyle" textmode="password" width="199px" autopostback="false"></asp:textbox>                 </div>          <div class="label">             <asp:label id="lblcaptcha" runat="server" text="security check"></asp:label>         </div>          <div class="value">            <!-- <cc1:captchacontrol id="ccjoin" runat="server" captchabackgroundnoise="none" captchalength="5" captchaheight="60" captchawidth="200" captchalinenoise="none" captchamintimeout="5" captchamaxtimeout="240" />  -->         </div>          <div class="label">             <asp:label id="lblentercaptcha" runat="server" text="enter value"></asp:label>         </div>          <div class="value">             <asp:textbox id="txtcaptcha" runat="server" cssclass="txtstyle" width="199px" autopostback="false"></asp:textbox><br /><br />             <asp:button id="btnlogin" runat="server" width="60" text="login" cssclass="btnstyle"/>         </div>     </div>     </form>     <img id="img1" src="styles/impact_logo.png" style="text-align:right;text-shadow:black;margin-left:800px" /> </body> </html> 

selectcompany.aspx **

<%@ page title="" language="c#" masterpagefile="~/master1.master" autoeventwireup="true" codebehind="~/forms/selectcompany.aspx.cs" inherits="flexstock.forms.selectcompany" enableviewstatemac="false" %> <asp:content id="content1" contentplaceholderid="head" runat="server">     <link rel="stylesheet" type="text/css" href="../styles/selectcompany.css" />     <link rel="stylesheet" type="text/css" href="../styles/main.css" />   </asp:content> <asp:content id="content2" contentplaceholderid="contentplaceholder1" runat="server">     <form id="frmselectcompany" enableviewstate="false">         <div id="label" class="label" style="width:300px">             <asp:label id="lblselectcompany" runat="server" text="select company or create new"></asp:label>         </div>         <div id="btncreate" style="text-align:right">             <asp:button id="btncreatenew" runat="server" text="create new" cssclass="btnstyle" />         </div><br />          <div id="divgrid">         </div>      </form>  </asp:content> 

this pretty common error see. it's security feature in asp.net prevents injecting additional controls onto page after has rendered, , posting controls server. makes website harder hack.

are creating input controls through javascript? if so, don't. create controls inside web form , wrap them in <div style='display:none;'> , display them when need them.

are creating controls dynamically within c#? - if are, must create them inside page_init, not page_load, otherwise asp.net won't recognise them valid.

you can disable security measure setting enableviewstatemac=false @ top of aspx page, advise against it.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -