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?
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