Reputation: 349
I published an ASP.NET Web Application 4.0
and moved it the server. When users log in to their machines using Windows authentication
and then go to the Web app page in the browser, their user name should be displayed on the aspx page.
On the server, Windows authentication
is set to true and anonymous access is disabled.
However, the user name is not displayed on the aspx page. "Welcome Not authenticated" is displayed instead. Did I miss anything? Any pointers are appreciated.
This code is in SiteMaster.cs:
public partial class SiteMaster : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
{
divWelcome.InnerHtml = "Welcome " + System.Web.HttpContext.Current.User.Identity.Name;
}
else
{
divWelcome.InnerHtml = "Welcome " + "Not authenticated";
}
}
}
I don't know if this has to be modified in Web.config
. I'm not using the Login functionality as anyone at work can access the page:
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
Upvotes: 1
Views: 611
Reputation: 83
try changing it to
<authentication mode="Windows" />
This should fix it..
Upvotes: 2