Ryan McDonough

Access Umbraco back office user from the front end

If you need to access the current user logged into the Umbraco Backoffice from the Front End (to show a link to administrator area for example) you may have tried:


None of which seem to work, then you should user the following code:

@using Umbraco.Core.Security;
var userTicket = new System.Web.HttpContextWrapper(System.Web.HttpContext.Current).GetUmbracoAuthTicket();
if (userTicket != null) {     
 var currentUser = ApplicationContext.Services.UserService.GetByUsername(userTicket.Name);

As Andrew Wilson mentions in the comments, remember to include Umbraco.Core.Security – though if you forget hopefully Visual Studio will tell you to add it.

Version 8 Note

As Corey mentions in the comments, remember to include:

@using Umbraco.Web.Security;

For Umbraco 8 onwards.