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)
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.
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();
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
current login user
hi folks.,
how to retrieve current login user? ie username
umbraco.BasePages.UmbracoEnsuredPage.CurrentUser; what will this return?
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
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
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
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 you are using your control in the website you can get the member via
More info http://our.umbraco.org/wiki/how-tos/membership-providers
In both cases you can use the debugging technique Nik described.
Cheers,
Richard
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
oh i got it ..thanks.. !!!
is working on a reply...