I have he following method inside my action method:-
repository.InsertOrUpdateRack(rj.Rack, User.Identity.Name, assetid);
But the user name generated from User.Identity.Name
will prefix the username with the domain name as follow:-
DOMAINNAME\username
So is there a way to force the User.Identity.Name
to retrieve the username only?
Thanks.
var userName = WindowsIdentity.GetCurrent().Name.Split('\\').Last();
in case there is no domain prefix – Gause