use Thread.CurrentPrincipal instead of HttpContext.User in a web application?

  • Thread starter Thread starter Novice
  • Start date Start date
N

Novice

Is there ever an instance in which a developer should use
Thread.CurrentPrincipal in a web application instead of
HttpContext.User?

By this I mean should I be assigning the object (whose class extends
IPrincipal) that represents a particular web user to:
HttpContext.User
in all instances instead of:
Thread.CurrentPrincipal

I'm implementing a typical ecommerce web application that has numerous
products and users. It is basically being used to connect the two.
My DBMS stores user information and when they log in, I validate their
information against the DBMS and then give them access or deny them
access. If I give them access, shouldn't I be assigning the
GenericPrincipal object to HttpContext.User instead of
Thread.CurrentPrincipal?

Thanks,
Novice
 
as asp.net can switch threads during a page request (thread agility), you
should use HttpContext, so any changes will be reflected for the complete
process of a page.

-- bruce (sqlwork.com)
 
Back
Top