Wednesday, June 5, 2019

How may I get the User.Identity.Name that I am used to getting in a .NET Core controller from an ExceptionContext?

string name = context?.HttpContext?.User?.Identity?.Name;

If you follow my whole Middleware for logging and catching exceptions paradigm as suggested here you may want to log who the user at hand is as part of your record writing. This should help with that.

No comments:

Post a Comment