Viewstate error when using asp.net form 4.5 template forms authentication

  1. #1

    Viewstate error when using asp.net form 4.5 template forms authentication

    using the asp.net 4.5 template from VS 2013 with forms authentication.

    The standard template works fine. But when I insert this code in the asp.net file Site.Master

    <asp:ContentPlaceHolder runat="server" ID="HeaderContent"/>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" >  </ext:ResourceManager>
            <asp:ScriptManager runat="server">
                <Scripts>
                    <%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=301884 --%>
                    <%--Framework Scripts--%>
                    <asp:ScriptReference Name="MsAjaxBundle" />
                    <asp:ScriptReference Name="jquery" />
    when try logging in or logout. This will set the property

    Page.ViewStateUserKey = _antiXsrfTokenValue; "from the template code behind in site.master in method page_init

    and it will fail with

    Server Error in '/' Application.
    --------------------------------------------------------------------------------
    
    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\73ff2d36\2103949\App_Web_kfycqcv3.3.cs    Line:  0 
    
    Stack Trace: 
    
    [ArgumentNullException: Value cannot be null.
    Parameter name: inputString]
       System.Web.UI.ObjectStateFormatter.Deserialize(String inputString, Purpose purpose) +9871443
       System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter2.Deserialize(String serializedState, Purpose purpose) +8
       System.Web.UI.Util.DeserializeWithAssert(IStateFormatter2 formatter, String serializedState, Purpose purpose) +40
       System.Web.UI.HiddenFieldPageStatePersister.Load() +127
    
    [ViewStateException: Invalid viewstate. 
        Client IP: ::1
        Port: 20080
        Referer: http://localhost:10260/Account/Login
        Path: /Account/Login
        User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)
        ViewState: ]
    
    [HttpException (0x80004005): The state
    I have tried the different combinations on the Ext:ResourceManager like DisableViewState="true" EnableViewState="false" . I believe the Ext is not supposed to tamper with the viewstate, so this error makes no sense ?
    Last edited by geoffrey.mcgill; Feb 15, 2014 at 1:47 PM. Reason: Please use [CODE] tags
  2. #2

    Solved

    It seems that these properties will render ok

    <ext:ResourceManager ID="ResourceManager1" runat="server" DisableViewState="false" EnableViewState="true" >  </ext:ResourceManager>
    I still does not make sense to me due to ext is not supposed to work with viewstate.
    Last edited by geoffrey.mcgill; Feb 15, 2014 at 1:46 PM. Reason: Please use [CODE] tags
  3. #3
    Hi @hjh,

    Ext.NET disables ViewState by default, because Ext.NET doesn't require it.

    Though, if the form authentication is used, ViewState should be enabled.

    Please check the System.Web.Security.FormsAuthentication.IsEnabled property. Is it true or false?

Similar Threads

  1. Forms Authentication with Single Page App
    By glenh in forum 2.x Help
    Replies: 1
    Last Post: Feb 13, 2014, 11:38 PM
  2. [CLOSED] Forms authentication RedirectFromLoginPage not working
    By CarWise in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Jun 05, 2012, 1:25 PM
  3. [CLOSED] AjaxMethod and Forms authentication
    By tdracz in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 20, 2009, 7:57 PM
  4. Replies: 4
    Last Post: May 07, 2009, 11:44 PM
  5. [CLOSED] Forms Authentication and Coolite (Ext)
    By reinout.mechant@imprss.be in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 04, 2009, 11:18 AM

Tags for this Thread

Posting Permissions