jQuery选项卡导致回发错误

时间:2013-10-02 18:37:58

标签: jquery asp.net webforms

我有一个带有JQuery选项卡的应用程序来显示我的所有内容。一切正常,但当用户选择退出按钮时,它会回发并出现以下错误

   The state information is invalid for this page and might be corrupted. 
   Description: 
   An unhandled exception occurred during the execution of the current web request.     
   Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: The state information is invalid for this page and might be corrupted.

Source Error: 


[No relevant source lines]


Source File: c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\627a9c02\870fb5b3\App_Web_default.aspx.cdcab7d2.lrjt4utr.0.cs    Line: 0 

Stack Trace: 


[FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or a non-white space character among the padding characters. ]
System.Convert.FromBase64String(String s) +0
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +77
System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4
System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +37
System.Web.UI.HiddenFieldPageStatePersister.Load() +147

[ViewStateException: Invalid viewstate. 
Client IP: 127.0.0.1
Port: 
Referer: http://localhost:1237/default.aspx
Path: /default.aspx
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; InfoPath.3)
ViewState: /wEPDwUKMjA4ODU5NDYwMWQYAgUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgMFNWN0bDAwJE1haW5Db250ZW50JEhlYWRMb2dpblZpZXckSGVhZExvZ2luU3RhdHVzJGN0bDAxBTVjdGwwMCRNYWluQ29udGVudCRIZWFkTG9naW5WaWV3JEhlYWRMb2dpblN0YXR1cyRjdGwwMwUmY3RsMDAkTWFpbkNvbnRlbnQkTG9naW5Vc2VyJFJlbWVtYmVyTWUFH2N0bDAwJE1haW5Db250ZW50JEhlYWRMb2dpblZpZXcPD2QCAWQ32uen3eiriKYlE49WCOp7gXtn08ext+/697YeD7DxzQ==,/wEPDwUJMzg1OTg5NDIxZGQnnUqYiBZZWyHLBN0PExZlAOJfaAuIjtM4PahUembbmA==]

[HttpException (0x80004005): The state information is invalid for this page and might be corrupted.]
System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +235
System.Web.UI.ViewStateException.ThrowViewStateError(Exception inner, String persistedState) +14
System.Web.UI.HiddenFieldPageStatePersister.Load() +251
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +106
System.Web.UI.Page.LoadAllState() +43
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +8431
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +253
System.Web.UI.Page.ProcessRequest() +78
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.default_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\627a9c02\870fb5b3\App_Web_default.aspx.cdcab7d2.lrjt4utr.0.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

我的默认页面代码在这里

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CCIQARewrite.Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">

<script type="text/javascript">



     $(document).ready(function () {

           $("#tabs").tabs();

         });
    </script>
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <form id="Form1" runat="server">
    <div class="page">
    <div class="header">
        <div class="title">
            <h1>
                &nbsp;<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/CCLogo.jpg" />
            </h1>
        </div>
        <div class="loginDisplay">
            <asp:LoginView ID="HeadLoginView" runat="server"  ViewStateMode="Disabled">
                    <LoggedInTemplate>
                    Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!
                    [ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/Account/Login.aspx" /> ]
                </LoggedInTemplate>
            </asp:LoginView>
        </div>
        </div>  

<div class="clear">
<div id="tabs">


                  <ul>

                    <li><a href="My Audits.aspx" id="MyAuditsTab">My Audits</a></li>
                    <li><a href="My Claims.aspx">My Claims</a></li>
                    <%--<li><a href="Reports.aspx">Reports</a></li>
                    <li><a href="Maintenance.aspx">Maintenance</a></li>--%>

                  </ul>




        </div>
        </div>
        </div>


        <div id="login" style="display:none">


    <h2>
        Log In
    </h2>
    <p>
        Please enter your username and password.
        <asp:HyperLink ID="RegisterHyperLink" runat="server" EnableViewState="false">Register</asp:HyperLink> if you don't have an account.
        </p>
    <asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false">
        <LayoutTemplate>
        <span class="failureNotification">
            <asp:Literal ID="FailureText" runat="server"></asp:Literal>
        </span>
        <asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification" 
             ValidationGroup="LoginUserValidationGroup"/>
        <div class="accountInfo">
            <fieldset class="login">
                <legend>Account Information</legend>
                <p>
                    <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Username:</asp:Label>
                    <asp:TextBox ID="UserName" runat="server" CssClass="textEntry">  </asp:TextBox>
                    <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" 
                         CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required." 
                         ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
                </p>
                <p>
                    <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
                    <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" 
                         CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required." 
                         ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
                </p>
                <p>
                    <asp:CheckBox ID="RememberMe" runat="server"/>
                    <asp:Label ID="RememberMeLabel" runat="server" AssociatedControlID="RememberMe" CssClass="inline">Keep me logged in</asp:Label>
                </p>
            </fieldset>
            <p class="submitButton">
                <asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="LoginUserValidationGroup"/>
            </p>
        </div>
        </LayoutTemplate>
        </asp:Login>
       </div>
        </form>


    </asp:Content>

我知道选项卡与此错误有关,因为当我删除创建选项卡的Jquery时,它会回发而不会出错

1 个答案:

答案 0 :(得分:0)

不要自己执行__doPostBack();,而是在注销按钮上触发click事件,这将指示asp.net以适当的方式提出回发。

$('#yourlogoutselector').trigger('click'); //didn't find your logout button