How can you test whether the Windows user is authenticated?

 Posted by Ddd on 3/16/2011 | Category: ASP.NET Interview questions | Views: 2551 | Points: 40
Answer:

It can be done by using this code snippet

Write it in an event handler (Page_Load for example)

   if (User.Identity.IsAuthenticated == true)

{
Response.Write(User.Identity.Name + "---" + "authenticated");
}


It will display the Windows user name if authenticated


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Akiii on: 3/17/2011 | Points: 10
@Ddd......

Tested and working fine.....

Thanks and Regards
Akiii

Login to post response