c# - Where should I be retrieving the user principal in an ASP.NET Web Forms app? -


assuming general use case in asp.net web forms application, should retrieving principal + identity?

i'm aware there 2 ways go it:

  • httpcontext.current.user
  • thread.currentprincipal

i'm speculating using httpcontext run risk of current context not existing (i.e. httpcontext.current == null) on edge cases, more see code use instead of thread.currentprincipal (which assume safer, should exist?).

why this? implications getting myself if pick 1 or other?

rep whoring here come :)

mr. hanselman has blogged here: http://www.hanselman.com/blog/systemthreadingthreadcurrentprincipalvssystemwebhttpcontextcurrentuserorwhyformsauthenticationcanbesubtle.aspx

the basic idea 99% of time.. same.. although it's possible change them.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -