In an aspx page I get the Windows username with the function Request.LogonUserIdentity.Name. This function returns a string in the format \"domain\\user\".
Request.LogonUserIdentity.Name
Getting parts[1] is not a safe approach. I would prefer use LINQ .Last():
WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent(); if (windowsIdentity == null) throw new InvalidOperationException("WindowsIdentity is null"); string nameWithoutDomain = windowsIdentity.Name.Split('\\').Last();