ASP.NET Custom Principal Reverts to Generic on Postbacks

ASP.NET Custom Principal Reverts to Generic on Postbacks

Old forum URL: forums.lhotka.net/forums/t/823.aspx


Fiodhrid posted on Friday, August 04, 2006

Hello, all

I have a problem that is very similar to " GenericPrincipal error when logged in" which was posted on 6 June 2006 - that application was Windows, mine is ASP.

In ASP.NET 1.1, I am setting the AppDomainPrincipalPolicy.UnauthenticatedPrincipal then setting the AppDomain.SetThreadPrincipal to my Custom Principal successfully.

Then i set the Thread.CurrentPrincipal to my Custom Principal successfully.

From there, any postback causes both the Thread.CurrentPrincipal and the AppDomain thread principal to revert to an empty GenericPrincipal!! Not too big a deal on a page post since I do some page initializations and can reset it there. But I find that even a DataGrid button column click is causing the reversion to an empty GenericPrincipal.

Can anyone please help me get a clue as to what is going on here? Why won't my AppDomain and Thread maintain my CustomPrincipal??

tnx

Fio

RockfordLhotka replied on Friday, August 04, 2006

This is explained in Chapter 10. You need to reset the principal on every page request in global.asax.

Fiodhrid replied on Saturday, August 05, 2006

Got it. I haven't had a chance to try an implementation of this Global event in my application as yet, but I can see that this will solve my issue.

thanks so much.

Rocky, I can never thank you enough for all you've taught me thru your several iterations of "Expert Business Objects". Your books have become my bible - I never leave home without them.

THANKS!

ntimothys replied on Tuesday, October 22, 2013

Overridding Principal in:
protected void Application_PostAuthenticateRequest(object sender, EventArgs e)

Instead of
 protected void Application_AuthenticateRequest(object sender, EventArgs e)

In Global.asax.cs worked for me in an ASP web application

Copyright (c) Marimer LLC