Can ELMAH use context.User instead of Thread.CurrentPrincipal.Identity.Name when getting user name?

30 views
Skip to first unread message

Rinat Abdullin

unread,
Apr 29, 2008, 8:48:27 AM4/29/08
to ELMAH
Hi,

ELMAH is a really great tool that saves a lot of effort in exception
logging. Thank you for developing it!

I have on question, though. Can ELMAH use context.User instead of
Thread.CurrentPrincipal.Identity.Name when getting user name in the
Error constructor?

AFAIK, generally it is a better practice in web applications to use
the first approach instead of asking for CurrentPrincipal.

Best regards,
Rinat Abdullin

Atif Aziz

unread,
Apr 29, 2008, 5:48:52 PM4/29/08
to el...@googlegroups.com
>>
AFAIK, generally it is a better practice in web applications to use
the first approach instead of asking for CurrentPrincipal.
<<

In general, ASP.NET propagates HttpContext.User to Thread.CurrentPrincipal so it should be safe to rely on the latter. Nonetheless, you raise a good point and I'll review the decision in the Error constructor. Perhaps HttpContext.User can override the value taken from Thread.CurrentPrincipal where an HttpContext was supplied.

- Atif

Rinat Abdullin

unread,
May 1, 2008, 4:50:48 AM5/1/08
to ELMAH
Atif,

Thank you!

Best regards,
Rinat Abdullin
Reply all
Reply to author
Forward
0 new messages