Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
What's the best way to get the current logged in member in Umbraco 5.1?
I'm currently using
string username = User.Identity.Name; Umbraco.Framework.Security.Model.Entities.Member currentMember = RoutableRequestContext.Application.Security.Members.GetByUsername(username);
Where are you trying to get it? Surface controller or Razor?
In razor you can do
@{Member current = Umbraco.Members.GetCurrent();}
In a controller you can get the context in your constructur and use that
public class MyController : Controller{ private readonly IUmbracoApplicationContext _context; public MyController(IUmbracoApplicationContext context) { _context = context; } [HttpGet] public ActionResult DoStuff() { var member = _context.Security.Members.GetCurrent(); } }
Hmm. Was that answer accepted extremely fast, or did it somehow happen when I edited my post?
The answer was ideal! Thanks Morton
A fast response deserves a fast hy5!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Get Current User in Umbraco5.1
Hi,
What's the best way to get the current logged in member in Umbraco 5.1?
I'm currently using
Where are you trying to get it? Surface controller or Razor?
In razor you can do
In a controller you can get the context in your constructur and use that
Hmm. Was that answer accepted extremely fast, or did it somehow happen when I edited my post?
The answer was ideal! Thanks Morton
A fast response deserves a fast hy5!
is working on a reply...