Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nathan Reece 62 posts 376 karma points
    May 07, 2021 @ 03:25
    Nathan Reece
    0

    Umbraco 8 Can I check if a user is logged in within a razor view?

    Does any one know how to check if a backend 'User' is logged in from within a razor View? I have code that checks the membership but this just seems to be working for members and not backend users. I am hoping someone can point me in the right direction.

  • David Armitage 505 posts 2073 karma points
    May 07, 2021 @ 03:44
    David Armitage
    101

    Hi Nathan,

    This should help you.

    var userTicket = new System.Web.HttpContextWrapper(System.Web.HttpContext.Current).GetUmbracoAuthTicket();
    if (userTicket == null)
    {
        //the user is not autenticated
    }
    

    Kind Regards

    David

Please Sign in or register to post replies

Write your reply to:

Draft