How to pass Current User Information to all Layers in DDD

Viewed 6212

Similar questions have been asked before but not quite the same (unless I missed it)

I want to pass IUserInfo class instance through my Service, Domain , Domain Events, Domain Event Handlers...

Whats is the best way to do it.

Should I

  • Inject it using IoC by registering it against instance of Httpcontext.Current.session["CurrentUser"];

  • Add the data to Current Thread.

  • Any other way

I am stuck at Domain Event Handlers where I want to use the data for auditing as well as sending emails.

I want to be able to use the CurrentUser information from almost anywhere in my application.

With threading as threads are pooled I am skeptical if the reuse of threads will reset the data. If not please shopw me how to use threading to pass IUser instance.

Regards,

Mar

2 Answers
Related