Get Username for logged in user using ASP.net(c#.net)

Posted by Kavi.Sirius under ASP.NET on 5/11/2012 | Points: 10 | Views : 23955 | Status : [Member] | Replies : 8
hi,

I am having trouble getting a logged in username to use on an iis server. If I use User.Identity.Name.ToString I get a blank.
If I use Environment.UserName.ToString I get "Network Service".

If I run the application in debug locally I get the Domain\username but not when I run it on our iis server.

Regards
Kavi.n



Responses

Posted by: Kavi.Sirius on: 5/11/2012 [Member] Starter | Points: 25

Up
0
Down
hi,

Thank u for ur reply,
i already saw this site,
but is not working

Regards
Kavi.n

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kavi.Sirius on: 5/11/2012 [Member] Starter | Points: 25

Up
0
Down
Thank u for ur replies

Regards
Kavi.n

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nuwan on: 5/12/2012 [Member] Starter | Points: 25

Up
0
Down
If User.Identity.IsAuthenticated Then

Label17.Text = User.Identity.Name

Else

Label17.Text = "No user identity available."

End If

This is work perfectly

Rathnayake

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kavi.Sirius on: 5/12/2012 [Member] Starter | Points: 25

Up
0
Down
hi nuwan

this code work perfectly in localhost
but not work in iis server


Regards
Kavi.n

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nuwan on: 5/12/2012 [Member] Starter | Points: 25

Up
0
Down
Ok I will check it in iis.

Rathnayake

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nuwan on: 5/16/2012 [Member] Starter | Points: 25

Up
0
Down
You Can do that using Session, try it.

Rathnayake

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kavi.Sirius on: 5/16/2012 [Member] Starter | Points: 25

Up
0
Down
hi nuwan,

i cant get ur answer,
pls explain clearly

Regards
Kavi.n

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nuwan on: 5/16/2012 [Member] Starter | Points: 25

Up
0
Down
in Login Page.aspx

Session["user"] = this.TexUsername.Text;
Response.Redirect("ViewPage.aspx");

View Page.aspx

this.LblUsername.Text = Session["user"].ToString();

Try This code

Rathnayake

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response