Recipe: Enabling Windows Authentication within an Intranet ASP.NET Web application
page 6 of 10
by Scott Guthrie
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 36588/ 49

Outputting the Logged-in Username on a Page

You can use the username string we retrieved above to programmatically output the username to a page however you want.  For example, you could easily add an <asp:label> control to the page and write code like so to set it:

Label1.Text = "Welcome " & User.Identity.Name

ASP.NET 2.0 also ships with a built-in <asp:LoginName> control that you can use to declaratively output the user-name to the page:

<asp:LoginName ID="LoginName1" FormatString="Welcome {0}!" runat="server" />

This control provides an easy way to display the username within the application without having to write any code at all (note the use of the “FormatString” property on the control above – which allows you to easily specify a text mask to use with it).


View Entire Article

User Comments

Title: Help please   
Name: Kaustubh
Date: 2008-09-02 3:05:57 AM
Comment:
Hello,

I did same thing as u mentioned. But when I tried to open it through browser. it asks for windows user and password.

What could be reason ?
Title: HELP !   
Name: Bruce
Date: 2007-12-03 4:56:27 PM
Comment:
I've done this. When the browser is run from a W2K machine, I get "Cannot find server or DNS Error". When run from an XP machine, it appears to work just fine. Any ideas? Thanks.
Title: how to implement windows integrated authentication in java step by step   
Name: Shilpa
Date: 2007-08-16 3:12:57 AM
Comment:
Can I retrieve windows authentication in java
Title: Hi   
Name: Hello
Date: 2007-05-17 4:20:29 PM
Comment:
Super

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-16 1:28:24 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search