2010-06-08 60 views
2

我試圖將EnableViewStateMac設置爲false,但有時aspx頁面仍然會收到無效的ViewState錯誤。在這種情況下修改machine.config是不可能的。不知道該怎麼做。請幫忙!ASP.NET中的VIewState頁面無效

下面是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

也許這將有助於(美國),如果你發佈一個示例代碼,例如您在哪裏設置EnableViewStateMac。

但現在看起來,您的字段沒有正確啓動,所以不是true/false而是值爲「null」。但這只是一個猜測,現在推薦更多是不可能的。 ;)

+0

它不能爲空 – 2010-06-10 04:14:43

0

我已經得到了無效的viewstate錯誤之前,並在研究中,我認爲對我來說,問題發生在我的一個真正大的頁面。我讀了一些地方,真的很大的網頁可以有這個問題發生,因爲我現在忘記的原因...

+0

頁面只是100k,它不應該被評估爲一個大頁面 – 2010-06-10 04:15:35