Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)

Rate It (1)

Last post 04-20-2008 3:59 AM by zubairdotnet. 31 replies.

Sort Posts:

  • Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)

    01-30-2007, 1:10 PM
    • Loading...
    • Rama Krishna
    • Joined on 01-24-2006, 9:33 PM
    • Atlanta, GA
    • Posts 307

    I finally figured out what is causing the Sys.WebForms.PageRequestManagerServerErrorException. Here are the details of my research:

    It's probably a bug in the RoleManagerModule . The issue is that the RoleManagerModule, (which comes into picture when the role manager is enabled in the config) tries to add its cookie to Response's cookie collection. This is done in the EndRequest event of the Application. It should actually do it in the PreSendRequestHeaders event because the PreSendRequestHeaders is the last opportunity to modify the response headers. Under normal circumstances the  PreSendRequestHeaders  gets fired after the EndRequest event, but when Response.Flush is called the sequence may be reversed.

    Now, the changes made in AJAX RTM which causes this issue are in PageRequestManager.RenderFormCallback function. When EventValidation is enabled in the page, the function calls Response.Flush (which causes the header to be sent). In this case the Application's EndRequest event is fired after the headers have been sent so an exception occurs in RoleManagerModule when it tries to send the response headers. This eventually leads to the page manager parser exception on the client side because the error response is appended to the actual response sent by the partial update.

    There are three possible workarounds:

    1. Disable caching of cookies in the RoleManager. For custom modules append cookies in the PreSendRequestHeaders event and not EndRequest event.

    2. Handle the Application's Error event to clear the error from the Context selectively.

    void Application_Error(object sender, EventArgs e) 
    {
      //There should be some checking done so that not all the errors 
      //are cleared
      Context.ClearError();
    }

     3. Disable EventValidation in the web form.

    "C#" EnableEventValidation="false" %>
      <%@ Page Language="C#" EnableEventValidation="false" %> 

    The issue can be repro'ed easily by setting a cookie in the EndRequest event:

    void Application_EndRequest(object sender, EventArgs e)
    {
      Response.Cookies.Add(new HttpCookie("Test", "Test"));
    }

    And the following simple page will cause the issue:

     

    <%@ Page Language="C#" EnableEventValidation="true" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
             </div>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:Button ID="Button1" runat="server"  Text="Button" />
                    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                </ContentTemplate>
            </asp:UpdatePanel>
        </form>
    </body>
    </html>
    
     

  • Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)

    01-31-2007, 4:58 PM
    • Loading...
    • danehrig
    • Joined on 08-22-2006, 9:06 PM
    • Posts 49

    Very nice work!

     It seems like we're stuck between a rock and a hard place though.  We either have to give up cookie caching, event validation, or page error handling.  I'm curious about the part about the custom module though- I looked our our custom provider and didn't find either an endrequest or a presendrequestheaders event handler.  Are these events inherited from RoleManager?  If so how do we go about overriding them?


     

  • Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)

    01-31-2007, 5:06 PM
    • Loading...
    • Rama Krishna
    • Joined on 01-24-2006, 9:33 PM
    • Atlanta, GA
    • Posts 307
    It's the RoleManagerModule which does that not the RoleProvider. RoleManagerModule is the one responsible for maintaining the cookies. The problem occurs only when the list of cached roles changes. Now I have not researched much into when it happens. My guess is that with the custom provider it might be happening more, but I cannot validate it at this point. But the bug is in the rolemanager and not in ASP.NET AJAX.
  • Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)

    01-31-2007, 6:07 PM
    • Loading...
    • Luis Abreu
    • Joined on 02-12-2005, 6:22 AM
    • Madeira [Portugal]
    • Posts 5,077
    hello guys.

    Rama, great work!

    btw. I think you've missed a 4th option: writing a new rolemanager that works without any problems :)
    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    PT blog: http://weblogs.pontonetpt.com/luisabreu
    EN blog:http://msmvps.com/blogs/luisabreu
    http://www.pontonetpt.com
    http://weblogs.pontonetpt.com/
  • Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)

    02-05-2007, 10:47 AM
    Good work, thanks!
    When you ask a question, remember to click "mark as answered" when you get a reply which answers your question; this ensures the right forum member gets credit below for being helpful (and makes search more relevant too).
  • Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)

    02-06-2007, 11:07 AM
    • Loading...
    • wsmonroe
    • Joined on 04-11-2004, 10:16 AM
    • Posts 55

    I have run into this bug, as it appears many others have. I'm worried though, because it seems based on the other thread about this problem that everyone is able to get around the problem by using the first workaround (disabling cookie caching in the role manager), but in my application, that doesn't work. This troubles me. I am able to use the 3rd workaround (disable event validation on the page), so for the time being I'm OK, but I don't understand why the fix that works for everyone else doesn't work in my case.


    My situation is outlined below ... any idea why the disabling cookie caching for roles workaround won't work in this case?

    I am using roles, and the page that I am having problems with manipulates users and their roles, but I am NOT using a custom provider for roles. I am using the builtin ASP.NET Sql Role provider, and a connection to my SQL db to store roles data.

     

    My web.config, as it pertains to roles looks like:
     

     
    <roleManager enabled="true" cacheRolesInCookie="false" createPersistentCookie="false">
    	<providers>
    		<remove name="AspNetSqlRoleProvider" />
    		<add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
    	</providers>
    </roleManager>
    
    
    As for my page, it contains 3 update panels (all set to conditional updating). One panel contains un-editable user information. The 2nd lists all roles with checkboxes and a save button, allowing the admin to select which roles to put a user in. The 3rd is a list of linkbuttons to perform actions on a user (such as set IsApproved to true or false, or to unlock a locked out user). When I select some roles and click the save button in the 2nd UpdatePanel, or click one of the LinkButtons in the 3rd UpdatePanel, I get the PageRequestManagerServerErrorException error.

    As I said, I'm able to use the 3rd workaround suggestion (disable event validation on the page) to get around it, but I'm curious why disabling of cookie caching in the role manager doesn't work for me, when it DOES seem to work for everyone else ...

     

    The Wheel is turning and you can't slow it down, can't let go and you can't hold on. You Can't go back, and you can't stand still, If the thunder don't get ya then the lightning will!
  • Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)

    02-07-2007, 2:26 AM
    • Loading...
    • ilya_s
    • Joined on 02-07-2007, 7:21 AM
    • Posts 4

    Same issue here. Using one update panel with a asp:Login control inside. Have some customizations on login but nothing strange.Tried disabling caching roles in cookies, tired EnableEventValidation="false". Using AspNetSqlRoleProvider

    I am not sure the cause of the error is with rolemanger...

     BTW: It worked with no problem on the previous release of AJAX. Absolutely no issues.

    Also noticed another issue with the timer, but that should be another post.

    Anyone have a solution?

  • Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)

    02-07-2007, 5:57 AM
    • Loading...
    • Rama Krishna
    • Joined on 01-24-2006, 9:33 PM
    • Atlanta, GA
    • Posts 307
    Does the Login control work with the UpdatePanel? In my experience it does not. Can you post soe code here?
  • Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)

    02-08-2007, 5:35 AM
    • Loading...
    • ilya_s
    • Joined on 02-07-2007, 7:21 AM
    • Posts 4
    It did work before version 1.0... Same exact page after update does not work - tried all the workarounds
  • Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)

    02-16-2007, 5:59 AM
    • Loading...
    • ilya_s
    • Joined on 02-07-2007, 7:21 AM
    • Posts 4

    I have another site that works fine with a login control + update panel + master page... Anybody? Any ideas? I tried all the workarounds...

  • Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)

    02-27-2007, 3:30 PM
    • Loading...
    • jminond
    • Joined on 07-21-2003, 6:33 PM
    • New York
    • Posts 589

    Page EventValidation=false fixed my loginview inside an update panel, so try that suggestion from this thread, it should work.

    We had a number of different cases making this error, and EventValidation was the primary fix, nothing to do with rolemanager sutf.f

     

    Jonathan Minond
    http://www.Jonavi.com
    http://www.jonavi.com/Default.aspx?pageID=21
    http://RainbowBeta.com
    http://community.rainbowportal.net/blogs/jonathans_rainbow_blog/default.aspx
    http://dotnetslackers.com/community/blogs/jminond/default.aspx
  • Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)

    02-27-2007, 5:01 PM
    • Loading...
    • samdc
    • Joined on 12-21-2006, 11:55 PM
    • Posts 2

    Hi,

    I'm getting the same error.  My page has 1 gridview, label and a bunch of images inside the update panel.  The label displays the current DateTime.  It is a dashboard application that automatically does a partial postback every 5 minutes.  What consistently happens is that everytime the panel updates after midnight, this error message appears.  Now I have tried all the suggestions in this post, but still I get this error.  Any other ideas?

     Regards,

    Sam
     

  • Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)

    03-02-2007, 3:18 PM
    • Loading...
    • btolly
    • Joined on 03-02-2007, 8:11 PM
    • Posts 1

    I have been getting this error, gridview inside an updatepanel, on a timer - consistently gets the error within a few minutes.  The 3 solutions above did not work - I appear to have worked around it by handling the error on the client side with this javascript:

    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
    function EndRequestHandler(sender, args)
    {
      if (args.get_error() != undefined)
       {
           var errorMessage;
           if (args.get_response().get_statusCode() == '12029')
           {
            args.set_errorHandled(true);
           }
           else
           {
               // not my error so let the default behavior happen       }
       }
    }

    The error is harmless to me so all want to do is not bother the user with an alert - this does it, till they fix the problem wherever it is.

     

  • Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)

    03-22-2007, 11:44 AM
    • Loading...
    • ASPninja
    • Joined on 01-17-2007, 3:31 PM
    • Posts 7

    You may want to try setting ValidateRequest="false" in the Page declaration. It worked for me.

     -  Ryan

  • Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)

    04-11-2007, 9:20 AM
    • Loading...
    • diadiora
    • Joined on 03-22-2007, 7:25 AM
    • Moldova, Republic Of
    • Posts 83

    ok, try another simplest way:

    METHODE 4

    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="false"/>

    Console.WriteLine("...");

    Diadiora
    ~~~~~~~~~~~~
    Dont forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
Page 1 of 3 (32 items) 1 2 3 Next >