Loosing roles between two pages ?

From: Gilles Lambert (gntools_at_hotmail.com)
Date: 03/29/04


Date: Mon, 29 Mar 2004 01:53:12 -0800

Hi,

I try to use roles in a ASP .NET application after users are athentified
in this way :

Dim sRoles() As String = {"User1", "User2", "User2"}
With Thread.CurrentPrincipal
  Dim gi As New GenericIdentity(.Identity.Name)
  Dim gp = New GenericPrincipal(gi, sRoles)
  AppDomain.CurrentDomain.SetPrincipalPolicy _
    (PrincipalPolicy.UnauthenticatedPrincipal)
End With

Thread.CurrentPrincipal = gp

Then, if i test the IsInRole Method in the same page, it is ok :

Thread.CurrentPrincipal.IsInRole("User1") 'Returns True

But when i test this method in another following page, all roles are
lost (it returns always false).

So is it normal or should i do something else ?

Thanks for your answer and best regards.
Gilles

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Relevant Pages