how to update context.user without postback ...ing

S

Softlion

Hi,
I'm using form authentication in a user control with fires an onSignedOn
event to registered page controls,
so there is no need to postback a second time to reflect changes.

It seems the Context.User.Identity stays a GenericIdentity object even after
calling FormsAuthentication.SetAuthCookie, and there is no method in the
FormsAuthentication class to do that.

Is the source code for FormsAuthentication class available ?
Any workaround without postbacking ?

Thanks.
___________________
http://www.softlion.com/
Web tools and games
 
D

Dominick Baier

Context.User gets populated after the postback by the formsauthentication
module. If you don't need a postback -set Context.User yourself.

Source code is available. As all the ASP.NET code is. Just google.
 
S

Softlion

From FormsAuthenticationModule.cs source code line 140 :

////////////////////////////////////////////////////////////
// Step 6: Create a user object for the ticket
e.Context.SetPrincipalNoDemand(new GenericPrincipal(new
FormsIdentity(ticket2), new String[0]));


SetPrincipalNoDemand is a non public function,
and Context.User is read only ....

Any other idea ?
 
S

Softlion

Maybe not in fact. There is a public set which calls SetPrincipalNoDemand.

So :
Context.User = new GenericPrincipal(new FormsIdentity(ticket2), new
String[0]);
should be sufficient ?


(from HttpContext.cs):

public IPrincipal User {
get { return _user; }
[SecurityPermission(SecurityAction.Demand, ControlPrincipal=true)]
set {
SetPrincipalNoDemand(value);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top