Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MVC HttpContext

Status
Not open for further replies.

Turpis

Programmer
Apr 16, 2002
151
Is there a way to get the same result as the WebForms HttpContext.User.Identity.Name.ToString() to get the username in MVC?

I tried this in my controller and it just comes back blank. The purpose is common across our intranet, when a record is created or update the user name and date is recorded on that record.

Also, since our entire intranet security schema is dependent on AD security so I suppose HttpContext.User.IsInRole("GroupName") isn't going to work either. Good old separation of duties...so how do I know who the user is without login pages?

Love learning new concepts (NOT)...makes me feel like a nube.

Charles
Business Systems/Developer
 
HttpContext is part of the asp.net framework, webforms just references the context, it doesn't define the context. same is true of MVC. I believe MS MVC offers abstraction on top of the context, request, response, etc. to allow for easier testing.

The purpose is common across our intranet, when a record is created or update the user name and date is recorded on that record
if that's the case then I don't think the controller is the appropriate place for this type of code. I would decorate the repository or use an AOP design so this happens automatically any time the state of the domain changes.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top