Hi Victor,
I don't understand why the custom IPrincipal object will lose custom
information, unless the IPrincipal object is not the custom one already. I
mean: if your class implements IPrincipal and create the instance in
Application_AuthenticateRequest and assign to Context.User, it should keep
the reference and you can always cast it to your custom class when used. If
you only see the Name, IsAuthenticated, AuthenticationType properties,
that's because the reference type is IPrincipal. You need to cast it to
your custom class:
CustomPrincipal myPrincipal = (CustomPrincipal) HttpContext.Current.User;
Above code is about the custom IPrincipal, I understand you're implementing
a custom IIdentity, which is accessed from IPrincipal.Identity, which also
need to cast to your cusom implementation class to access those custom
information you added.
Take a step back to look at your question, I understand you only need to
store some information for the current logined user, I think customizing
the IPrincipal and IIdentity may not be needed. Based on my understanding,
such information should be ok if we store them in the Session and use a
well known key to access them, I'm wondering why you think the Session is
not appropriate here?
Regards,
Walter Wang (
[email protected], remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.