locked
JavaScript runtime error: Unable to get property 'PRM_ParserErrorDetails' of undefined or null reference after asp.net Identity Auth cookie expires? RRS feed

  • Question

  • User-609535877 posted

    I implemented a simple web form application using Identity 2.0 to authenticate user from Visual studio. One web form contains UpdatePanel for partial update. Before cookie expires it works but after the cookie expires if I click a server button within UpdatePanel, got 0x800a138f - JavaScript runtime error: Unable to get property 'PRM_ParserErrorDetails' of undefined or null reference which blocks post back.

                app.UseCookieAuthentication(new CookieAuthenticationOptions
                {
                    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                    LoginPath = new PathString("/Account/Login"),

                    Provider = new CookieAuthenticationProvider
                    {
                        OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
                            validateInterval: TimeSpan.FromMinutes(10),
                            regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                    },
                    SlidingExpiration = true,
                    ExpireTimeSpan = TimeSpan.FromMinutes(20)
                });

               validateInterval: TimeSpan.FromMinutes(10),

               regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))

             },

        SlidingExpiration = true,

            ExpireTimeSpan = TimeSpan.FromMinutes(20)

           });

    How do I solve this javascript error?

    Tuesday, January 14, 2020 8:29 PM

All replies

  • User475983607 posted

    The POST is not blocked, the framework redirects to the login page when the request is not authenticated.  Write code in the app_endRequest event to detect if there was a redirect to the login page.  Then redirect to the login page using window.location so the user can login again.

    https://stackoverflow.com/questions/8373890/ajax-update-panel-session-time-out-issue

    Tuesday, January 14, 2020 9:24 PM
  • User-609535877 posted

    Thank you so much mgebhard. I put JavaScript function you mentioned in your link before the UpdatePanel for testing and run the application.

    These two event are triggered when clicking Submit button and always get undefined for BeginRequest and null for EndRequest. When cookie expires I click Button and get undefined value then the javascript error  "Unable to get property 'PRM_ParserErrorDetails' of undefined or null reference" pops up.

    It sounds the jacascript condition if (args._error != null) never satisfied. What am I missing?

     <script type="text/javascript">       
     Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

            function EndRequestHandler(sender, args) {
                alert("End " + args._error);
                if (args._error != null) {
                    if (args._error.name == "Sys.WebForms.PageRequestManagerParserErrorException") {
                        alert("Your session has expired");
                        args._error.message = "Your session has expired";
                        args._errorHandled = true;
                        parent.window.location.href = '/Account/Login.asp';
                        return false;
                    }
                }
            }

            function BeginRequestHandler(sender, args) {
                alert("Begin " + args._error);
                if (args._error != null) {
                    alert(args._error.name);
                    if (args._error.name == "Sys.WebForms.PageRequestManagerParserErrorException") {
                        alert("Your session has expired");
                        args._error.message = "Your session has expired";
                        args._errorHandled = true;
                        parent.window.location.href = '/Account/Login.asp';
                        return false;
                    }
                }
            }
        </script>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">

    Wednesday, January 15, 2020 8:35 PM
  • User475983607 posted

    I was able to reproduce the error and the response is standard Access Denied HTML page which is not the format the Update Panels expects and why you see the parsing error.  Unfortunately, the error happens before the end response event and I honestly have no idea how to catch the error.

    Wednesday, January 15, 2020 10:35 PM
  • User-609535877 posted

    Thank you so much for your help, mgebhard!

    Thursday, January 16, 2020 3:15 PM