2

I need to store an ID against a user that will be used in EVERY action that is carried out on my web application. I had hoped to use a customized authorization ActionFilterAttribute (on an entire controller) to populate the ViewData with this additional info, but it turns out that a whole STACK of stuff runs before these ActionFilterAttributes do e.g. ModelBinding, Controller construction

I thought perhaps there may be a way to extend the HttpContext.User.Identity to store additional data but have no idea even where to start.

Any ideas?

Jimbo
  • 21,476
  • 39
  • 113
  • 157

2 Answers2

1

SOLUTION
Looking around in more detail on StackOverflow I came across this solution that does EXACTLY what I want and in a super clean and proper way (HINT: It uses the userData property of the FormsAuthenticationCookie - https://stackoverflow.com/a/10524305/175893

Community
  • 1
  • 1
Jimbo
  • 21,476
  • 39
  • 113
  • 157
0

One option is to have a global (static) ConcurrentDictionary and store any additional information regarding the identity/user there - use whatever is convenient as a key... since this dictionary is thread-safe and implemented mostly lock-free it provides excellent performance... this way you don't need to mess around with any ASP.NET-specific stuff...

Yahia
  • 68,257
  • 8
  • 107
  • 138