Invalid VIewState in ASP.NET page
I have tried to set EnableViewStateMac to false but sometime the aspx page still gets the Invalid ViewState error. Modifying machine.config is impossible in this case. Don't know what to do. Please help!
Here is the ASPX code:
<%@ Page Language="C#" MasterPageFile="~/CommonPage.Master" Codebehind="Register.aspx.cs" EnableViewStateMac="false"
Inherits="xxxxxxxx.Register" Title="Create a new Account" %>
<%@ Register TagPrefix="usc" Namespace="xxxxxx" Assembly="xxxxxxxx" %>
<%@ Register Assembly="RadComboBox.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>
<asp:Content ID="c" ContentPlaceHolderID="content" runat="Server">
<div class="t_padleft">
<div class="t_failure" runat="server" visible="False" id="divFailure"></div>
<div class="t_success" runat="server" visible="False" id="divSuccess"></div>
<asp:PlaceHolder ID="phRegister" runat="server">
<h2 class="top">
Login Information</h2>
<table class="form">
<tr>
<td class="lbl">
Your Email</td>
<td class="field">
<asp:TextBox ID="txtEmail" runat="server" CssClass="txt"></asp:TextBox>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvEmail" runat="server" ControlToValidate="txtEmail"
Display="Dynamic" ErrorMessage="Please enter your e-mail address."></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="revEmail" runat="server" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ControlToValidate="txtEmail" Display="Dynamic" ErrorMessage="E-mail address is invalid."></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td class="lbl">
Password</td>
<td class="field">
<asp:TextBox ID="txtPassword" TextMode="Password" runat="server" CssClass="txt"></asp:TextBox></td>
</tr>
<tr>
<td>
</td>
<td>
<asp:RegularExpressionValidator id="revPasswordIsInvalid" runat="server" ErrorMessage="Accepted characters are: a->z, A->Z, _, and 0->9.<br />Password's length must be between 5 to 40"
ControlToValidate="txtPassword" ValidationExpression="\w{5,40}" Display="Dynamic"></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="rfvPass" runat="server" ControlToValidate="txtPassword"
Display="Dynamic" ErrorMessage="Please enter password."></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td class="lbl">
Verify Password</td>
<td class="field">
<asp:TextBox ID="txtVerifyPassword" TextMode="Password" runat="server" CssClass="txt"></asp:TextBox></td>
</tr>
<tr>
<td>
</td>
<td>
<asp:CompareValidator id="cvInvalidConfirmPassword" runat="server" ErrorMessage="The Verify Password does not match the Password"
ControlToValidate="txtVerifyPassword" ControlToCompare="txtPassword" Display="Dynamic"></asp:CompareValidator>
<asp:RequiredFieldValidator ID="rfvConfirm" runat="server" ControlToValidate="txtVerifyPassword"
Display="Dynamic" ErrorMessage="Please enter confirm password."></asp:RequiredFieldValidator>
</td>
</tr>
</table>
<h2>
Your Personal Information</h2>
<table class="form">
<tr>
<td class="lbl">
First Name</td>
<td class="field">
<asp:TextBox ID="txtFirstName" runat="server" CssClass="txt"></asp:TextBox>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvFirstName" runat="server" ControlToValidate="txtFirstName"
Display="Dynamic" ErrorMessage="Please enter your first name."></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td class="lbl">
Last Name</td>
<td class="field">
<asp:TextBox ID="txtLastName" runat="server" CssClass="txt"></asp:TextBox></td>
</tr>
<tr>
<td>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvLastName" runat="server" ControlToValidate="txtLastName"
Display="Dynamic" ErrorMessage="Please enter your last name."></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td class="lbl">
Country</td>
<td class="field">
<rad:RadComboBox ID="cbxCountry" runat="server" Width="336px" Height="150px" MarkFirstMatch="true" Skin="UltimateBlack" OffsetX="2"></rad:RadComboBox>
</td>
</tr>
<tr style="padding-top: 4px">
<td class="lblnotrequired">
Company Name</td>
<td class="fieldnotrequired">
<asp:TextBox ID="txtCompany" runat="server" CssClass="txt"></asp:TextBox></td>
</tr>
<tr>
<td class="lbl">
Time Zone</td>
<td class="field">
<rad:RadComboBox ID="cbxTimeZone" runat="server" Wi开发者_StackOverflow中文版dth="336px" Height="150px" MarkFirstMatch="true" Skin="UltimateBlack" OffsetX="2"></rad:RadComboBox>
</td>
</tr>
<tr>
<td>
</td>
<td class="formbtn">
<asp:Button ID="btnRegister" runat="server" OnClick="btnRegister_Click" CssClass="btn"
Text="Register" /></td>
</tr>
</table>
</asp:PlaceHolder>
</div>
</asp:Content>
Maybe it will help (us), if you post a example code, e.g. where you are setting EnableViewStateMac.
But for now, it looks like, your field is not correctly initiated, so instead of true/false it has the value "null". But it´s just a guess, recommending more is quiet impossible for now. ;)
I've gotten invalid viewstate errors before, and in researching, I think for me the issue was happening is in one of my really large pages. I read somewhere that really large pages can have that issue happen, for a reason I now forget...
精彩评论