Compiler Error Message: CS1061: 'Umbraco.Web.UmbracoHelper' does not contain a definition for 'Web' and no extension method 'Web' accepting a first argument of type 'Umbraco.Web.UmbracoHelper' could be found (are you missing a using directive or an assembly reference?)
No I need to be 'using' another namespace or is it no longer available in 7.4?
using Umbraco.Core.Security;
using Umbraco.Core.Models.Membership;
var authenticationTicket = new HttpContextWrapper(HttpContext.Current).GetUmbracoAuthTicket();
IUser user = null;
if (authenticationTicket != null)
{
user = UmbracoContext.Current.Application.Services.UserService.GetByUsername(authenticationTicket.Name);
}
else
{
// not logged into backoffice
}
// use it if not null
if(user != null)
{
var name = user.Name;
}
Compiler Error Message: CS1061: 'System.Web.HttpContextWrapper' does not contain a definition for 'GetUmbracoAuthTicket' and no extension method 'GetUmbracoAuthTicket' accepting a first argument of type 'System.Web.HttpContextWrapper' could be found (are you missing a using directive or an assembly reference?)
Current logged in user
I'd like to show the user id of the currently logged in user : I can get their name
but I'd also like to get their user id so I can store extra user into in a separate database and look it up on the page.
I did try
but I think that's from an older version of Umbraco as it crashed Umbraco 7.4
Have you tried:
var user = Umbraco.Web.UmbracoContext.Current.Security.CurrentUser;
? :)Doesn't work
No I need to be 'using' another namespace or is it no longer available in 7.4?
Hmm, are you doing this from a View?
This should work:
Sorry
Compiler Error Message: CS1061: 'System.Web.HttpContextWrapper' does not contain a definition for 'GetUmbracoAuthTicket' and no extension method 'GetUmbracoAuthTicket' accepting a first argument of type 'System.Web.HttpContextWrapper' could be found (are you missing a using directive or an assembly reference?)
Do you have
using Umbraco.Core.Security;
?Yes but user.Name returns their name not id.
Try
user.Id
instead then. :)I thought I had guessed that and it hadn't worked, but tried again and it has - that''s it!
Thanks for your help
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.