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();
}
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?
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.
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).
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:
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!
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.
Rama Krishna
Participant
1277 Points
307 Posts
Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)
Jan 30, 2007 05:10 PM|LINK
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.
<%@ 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:
danehrig
Member
85 Points
53 Posts
Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)
Jan 31, 2007 08:58 PM|LINK
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?
Rama Krishna
Participant
1277 Points
307 Posts
Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)
Jan 31, 2007 09:06 PM|LINK
Luis Abreu
All-Star
25674 Points
5369 Posts
MVP
Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)
Jan 31, 2007 10:07 PM|LINK
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
EN blog:http://msmvps.com/blogs/luisabreu
michiel1978
Participant
1205 Points
250 Posts
Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)
Feb 05, 2007 02:47 PM|LINK
wsmonroe
Member
132 Points
56 Posts
Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)
Feb 06, 2007 03:07 PM|LINK
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:
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 ...
ilya_s
Member
8 Points
4 Posts
Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)
Feb 07, 2007 06:26 AM|LINK
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?
Rama Krishna
Participant
1277 Points
307 Posts
Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)
Feb 07, 2007 09:57 AM|LINK
ilya_s
Member
8 Points
4 Posts
Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)
Feb 08, 2007 09:35 AM|LINK
ilya_s
Member
8 Points
4 Posts
Re: Sys.Webforms.PageRequestManagerServerErrorException actual cause (related RoleManager issue)
Feb 16, 2007 09:59 AM|LINK
I have another site that works fine with a login control + update panel + master page... Anybody? Any ideas? I tried all the workarounds...