I am trying to build an application on our company\'s intranet using ASP.NET and VB.NET.
Neither of these functions return anything once my application is published
Disable Anonymous Authentication in IIS.
User.Identity.Name might be empty if Anonymous Authentication is enabled in IIS.
Set in web.config
Use User.Identity.Name to get the logon user.
Environment.UserName is the running thread identity. If you have enabled Impersonation as Mark said, you can find out the returning result will be different. However this requires ASP.NET Impersionation. If you don't need ASP.NET Impersonation and dealing with the thread identity, you can ignore Environment.UserName if and just use User.Identity.Name.
Also check before perform any action.
if (User.Identity.IsAuthenticated)
{
Page.Title = "Home page for " + User.Identity.Name;
}
else
{
Page.Title = "Home page for guest user.";
}
Here is a good example