Copied to clipboard

Flag this post as spam?

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


  • Sa 118 posts 152 karma points
    Nov 13, 2009 @ 12:47
    Sa
    1

    current login user

    hi folks.,

    how to retrieve current login user? ie username

    umbraco.BasePages.UmbracoEnsuredPage.CurrentUser; what will this return?

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Nov 13, 2009 @ 13:13
    Richard Soeteman
    2

    This will return an User object and you can only use this in the umbraco interface. You can get the username by CurrentUser.LoginName (Make sure your page derives form UmbracoEnsuredPage)

    Cheers,

    Richard

     

     

     

  • Sa 118 posts 152 karma points
    Nov 13, 2009 @ 14:05
    Sa
    0

    Hello Richard.,thanks for quick response..

    how can i debug whether i can retrieve the current user or not..? as of now am getting some application error ..

    (regarding -Make sure your page derives form UmbracoEnsuredPage) as for as here i am using an userControl

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Nov 13, 2009 @ 14:34
    Nik Wahlberg
    0

    Hi Sam, in order to debug your install you should use "Attach to Process" in VS (assuming you are using this for development). This is made easier if you are developing locally on your machine as well. If you develop on a remote server (like shared dev environment), you can still attach to the remote server. See http://www.cprogramming.com/tutorial/visual_studio_remote_debugging.html.

    Cheers,
    Nik

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Nov 13, 2009 @ 15:51
    Richard Soeteman
    1

    Hi Sam, Do you use the usercontrol in the Umbraco admin interface or do you use it for the website. If you are using this in the Umbraco admin interface you can try this:

    if (Page is BasePage) 
    {
     //Okay we are in Umbraco 
     ((BasePage)Page).CurrentUser.LoginName;
    }

    If you are using your control in the website you can get the member via

    var member = System.Web.Security.Membership.GetUser();  

    More info http://our.umbraco.org/wiki/how-tos/membership-providers

    In both cases you can use the debugging technique Nik described.

    Cheers,

    Richard

  • Sa 118 posts 152 karma points
    Nov 16, 2009 @ 06:17
    Sa
    0

    i am using here an installer package(.ascx) to install custom section.. when the package is installed, logged in user and corresponding custom section should be inserted to umbracoUser2app table.. thats why am trying to retrieve  logged in user

  • Sa 118 posts 152 karma points
    Nov 16, 2009 @ 08:54
    Sa
    0

    oh i got it ..thanks.. !!!

Please Sign in or register to post replies

Write your reply to:

Draft