Discussion:
Needing to preserve a custom Principal...
Mike Andrews
2007-02-08 20:25:47 UTC
Permalink
Guys,

Is it possible to preserve a custom object that implements IPrincipal across
multiple pages in an ASP.NET 2.0 website?

I'm beginning to believe it's not and that I'll have to authenticate to
every page. Or is there something I'm missing?
I'm using Forms authentication.

Thanks,
Mike

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Efran Cobisi
2007-02-09 15:47:52 UTC
Permalink
Hi Mike,

Normally you would hold a token inside your FormsAuthentication ticket.
FormsAuthentication.RedirectFromLoginPage() method lets you store this
token that, in turn, would be available for subsequent authenticated
requests via Context.User.Identity property, which appears to be an
instance of the FormsIdentity type, under this kind of authentication.
Using that token would let you reload your custom IPrincipal
implementation on each subsequent request and assign it to the
Context.User, for the life of the request. Although I don't recommend
it, you could eventually save your custom IPrincipal istance in the
session state and later retrieve it, exploiting the aforementioned methods.

HTH,

Efran Cobisi
http://www.cobisi.com
Post by Mike Andrews
Guys,
Is it possible to preserve a custom object that implements IPrincipal across
multiple pages in an ASP.NET 2.0 website?
I'm beginning to believe it's not and that I'll have to authenticate to
every page. Or is there something I'm missing?
I'm using Forms authentication.
Thanks,
Mike
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Efran Cobisi
2007-02-09 16:13:19 UTC
Permalink
Or... You can implement a custom membership provider [1].
I was missing the easier way... My mistake.

[1] http://msdn2.microsoft.com/en-us/library/aa479048.aspx

HTH,

Efran Cobisi
http://www.cobisi.com
Post by Efran Cobisi
Hi Mike,
Normally you would hold a token inside your FormsAuthentication ticket.
FormsAuthentication.RedirectFromLoginPage() method lets you store this
token that, in turn, would be available for subsequent authenticated
requests via Context.User.Identity property, which appears to be an
instance of the FormsIdentity type, under this kind of authentication.
Using that token would let you reload your custom IPrincipal
implementation on each subsequent request and assign it to the
Context.User, for the life of the request. Although I don't recommend
it, you could eventually save your custom IPrincipal istance in the
session state and later retrieve it, exploiting the aforementioned methods.
HTH,
Efran Cobisi
http://www.cobisi.com
Post by Mike Andrews
Guys,
Is it possible to preserve a custom object that implements IPrincipal across
multiple pages in an ASP.NET 2.0 website?
I'm beginning to believe it's not and that I'll have to authenticate to
every page. Or is there something I'm missing?
I'm using Forms authentication.
Thanks,
Mike
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Continue reading on narkive:
Loading...