How to get username without domain

前端 未结 7 649
一整个雨季
一整个雨季 2021-02-06 21:12

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\".

7条回答
  •  醉话见心
    2021-02-06 21:43

    I was suggesting to use regexpes but they would be overkill. [System.String.Split](http://msdn.microsoft.com/en-us/library/b873y76a(VS.80).aspx) do the job.

    string[] parts= username.Split( new char[] {'\\'} );
    return parts[1];
    

提交回复
热议问题