Andornot Consulting
Friday, October 05, 2007 12:40 PM

ASP.NET AJAX Funky Exceptions Part II

by Ted Jardine

Back in the summer I described an issue with ASP.NET AJAX. The session solution dealt with things well enough (and note the update to simply disable session in a page-by-page basis for all but the pages requiring reading or writing to the session), but I'm still getting the occasional SystemWeb.HttpException where there's a problem with the RoleManager module:

Server cannot modify cookies after HTTP headers have been sent.

Stack trace: at System.Web.HttpCookieCollection.Add(HttpCookie cookie) at System.Web.Security.RoleManagerModule.OnLeave(Object source, EventArgs eventArgs)

Of course, because the user doesn't get what's going on (the user just gets the javascript alert box mentioned previously as I haven't intercepted the ASP.NET AJAX thrown error in this application - for this reason, I will be in all future applications), this exception is usually thrown multiple times until the user navigates to another page and then returns to try again. Some users are quite persistent (I recall one being close to 10 times) which would be humorous if it wasn't just so cruel and bad.

It turns out I've had to disable role caching as per the article I mentioned in the last post until either the ASP.NET Role Manager is fixed or I decide to write/find a custom role module. What's interesting is that the roles are not ever being changed in the pages throwing the exception! Harumph. Back to looking at jQuery from here on in.

Has anyone come up with a solution for this so that the roles data store is not being hit on every page load?

UPDATE: As per the comments below, apparently this has been fixed in ASP.NET 3.5, but there are no plans to back port the fix to 2.0.

 

Comments

10/17/2007 6:56:00 AM #

Rudi

Just reproduced the problem using a AJAZ enabled page and using the RoleManager. Set the cookie timeout to one minute and do a (AJAX) Postback and the Sys.Webforms.PageRequestManagerServerErrorException will occur. We solved the problem with a custom RoleProvider which puts the roles in the cache.

Rudi | Reply

6/3/2008 3:56:00 PM #

Eilon Lipton (Microsoft)

Hi there,
This turns out to be a known issue with the UpdatePanel due to how UpdatePanel has to render the page in a certain way. It turns out we fixed this bug in the version of AJAX that's in .NET 3.5. That version includes many fixes to the original AJAX 1.0.

Thanks,
Eilon

Eilon Lipton (Microsoft) | Reply

6/3/2008 5:02:00 PM #

Ted Jardine

Very nice to know that it has been resolved, but what about in 2.0?

It looks like we'll have to continue to use a custom RoleProvider.

Ted Jardine | Reply

6/3/2008 9:52:00 PM #

Ted Jardine

Eilon's response:

Hi Ted,
For now you'll have to use a workaround since we're not planning to back-port the fix to the older version.

Thanks,
Eilon

Ted Jardine | Reply

8/2/2008 7:29:00 AM #

Jason

I'm using the .NET 3.5 framework and am still receiving this issue. I read the comment from eilon lipton stating that this issue should of been fixed in the 3.5 framework version but, it doesn't appear to be...

I've tried all the other suggested fixes and none have worked for me...

Any other ideas..??

Jason | Reply

9/15/2008 1:55:00 PM #

SR

The asyncpostback event of scriptmanager can be used to overcome this problem

msdn.microsoft.com/.../....asyncpostbackerror.aspx

SR | Reply

3/20/2010 5:34:16 PM #

Maxi-Cosi

Erm, No!

Maxi-Cosi Russia | Reply

Add comment


(Will not be posted. Rather, will be used to show your Gravatar icon.)

  Country flag

biuquote
  • Comment
  • Preview
Loading