Re: (CustomIdentity)Thread.CurrentPrincipal.Identity - Cast not Va
From: Dominick Baier [DevelopMentor] (dbaier_at_pleasepleasenospamdevelop.com)
Date: 09/19/05
- Next message: Dominick Baier [DevelopMentor]: "Re: permissions & roles..."
- Previous message: Juan T. Llibre: "Re: permissions & roles..."
- Next in thread: Dominick Baier [DevelopMentor]: "Re: (CustomIdentity)Thread.CurrentPrincipal.Identity - Cast not Va"
- Maybe reply: Dominick Baier [DevelopMentor]: "Re: (CustomIdentity)Thread.CurrentPrincipal.Identity - Cast not Va"
- Maybe reply: Dominick Baier [DevelopMentor]: "Re: (CustomIdentity)Thread.CurrentPrincipal.Identity - Cast not Va"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Mon, 19 Sep 2005 12:01:09 -0700
Hello John,
WinForms works totally different than ASP.NET.
In ASP.NET you have to set the principal on each request. So after you set
it (besides that this code won't work correctly at all in ASP.NET) - you
redirect to to session.aspx - this gets served by a different thread - and
your principal is lost
You should use forms authentication and handle the Authenticate_Request.
Have you had a look at Forms Authentication before?
---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com
> ----Logon.aspx-------------
> //SET Thread.CurrentPrincipal
> CustomIdentity id = new CustomIdentity(userTable);
> CustomPrincipal p = new CustomPrincipal(id,roles);
> System.AppDomain.CurrentDomain.SetThreadPrincipal(p);
> Response.Redirect("SessionInfo", true);
> ----SessionInfo.aspx-------
> //GET Thread.CurrentPrincipal
> private void Page_Load(object sender, System.EventArgs e)
> {
> CustomPrincipal p = (CustomPrincipal)(Thread.CurrentPrincipal);
> CustomIdentity id = (CustomIdentity)p.Identity; //INVALID CAST ERROR
> }
> If I use a GenericPrincipal and GenericIdentity it works fine.
> As soon as I use my CustomPrincipal and CustomIdentity it fails (in
> asp.net
> only)
> The same code, same class used by a test WinForms app works fine.
- Next message: Dominick Baier [DevelopMentor]: "Re: permissions & roles..."
- Previous message: Juan T. Llibre: "Re: permissions & roles..."
- Next in thread: Dominick Baier [DevelopMentor]: "Re: (CustomIdentity)Thread.CurrentPrincipal.Identity - Cast not Va"
- Maybe reply: Dominick Baier [DevelopMentor]: "Re: (CustomIdentity)Thread.CurrentPrincipal.Identity - Cast not Va"
- Maybe reply: Dominick Baier [DevelopMentor]: "Re: (CustomIdentity)Thread.CurrentPrincipal.Identity - Cast not Va"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|
|