This project has moved. For the latest updates, please go here.

web.CurrentUser getting as "i:0#.f|membershipprovider|user"

Mar 5, 2012 at 1:42 PM

Hi,

I have downloaded FBA Pack source code from codeplex and customized  new Registration Form as per my needs using with Membership Request webpart.

When a user requested for membership his name is "User1" in User Name column in UsersDisp.aspx page. At the same time i am saving that user details in Register named list. 

I have saved User1 name in 'Created By' sharepoint list default column. This is all working fine.

But after log with above user, i am getting user name as "i:0#.f|membershipprovider|user1" in

SPWeb web = SPControl.GetContextWeb(this.Context); 

if (this.Context.User.Identity.IsAuthenticated)           

{                   

currentuser = web.CurrentUser.Name;             

}

but displaying name as 'User1' in ribbon top left.

Coordinator
Mar 5, 2012 at 1:59 PM

That's right - that's what SharePoint understands as the username.  To get the display name, you actually have to query SharePoint. Take a look at Layouts\Fba\Managements\UserEdit.aspx.cs - OnLoad, that has an example.