我尝试将EnableViewStateMac设置为false,但有时aspx页面仍然会收到Invalid ViewState错误。在这种情况下,修改machine.config是不可能的。不知道该怎么办。请帮忙!
这是ASPX代码:
<%@ 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" Width="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>
答案 0 :(得分:0)
如果您发布示例代码,也许它会对我们有帮助,例如:您在哪里设置EnableViewStateMac。
但是现在,看起来,你的字段没有正确启动,所以它的值为“null”而不是true / false。但这只是一个猜测,现在推荐更多是不可能的。 ;)
答案 1 :(得分:0)
我之前遇到了无效的viewstate错误,在研究中,我认为我发生的问题出现在我的一个非常大的页面中。我读到某个地方,真正的大页面可能会发生这个问题,原因我现在忘了...