tags:

views:

284

answers:

3

On a System.Web.UI.Page.ViewPage I have access to the current User (System.Security.Principal.IPrincipal) but I don't have access to the User through a System.Web.UI.UserControl.ViewUserControl (the ViewPage property is internal).

How can my partial view (.ascx) display information depending on who the IPrincipal is?

+1  A: 
HttpContext.Current.User
Mehrdad Afshari
Ok -- this is old, but I stumbled on it anyway ;0If you do this, you will break unit testing -- use ViewContext.HttpContext.* which uses HttpContextBase and was designed for unit testing.
Ethan J. Brown
+7  A: 
ViewContext.HttpContext.User
Marwan Aouida
This answer is more correct for ASP.NET MVC
eu-ge-ne
+1  A: 

You can get to it via the ViewContext

ViewContext.HttpContext.User
sighohwell