Thursday, March 11, 2010

getting login username using c#.net code for asp.net web app

ad this line to .cs file ::   using System.Security.Principal;


copy this code in .cs file




protected void Page_Load(object sender, EventArgs e)
    {


        string a;


        a = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
        string[] b = a.Split('\\');


        Label1.Text = b[1].ToString();
        string username = b[1].ToString();
        Label1.Text = username;
    }




in default.aspx page :


add this ::



then run it u will get user name in label. for more info plz do reply it or comment on it

No comments: