C# Windows身份验证:网页上未显示用户名
我发布了一个C# Windows身份验证:网页上未显示用户名,c#,authentication,iis,C#,Authentication,Iis,我发布了一个ASP.NET Web应用程序4.0,并将其移动到服务器上。当用户使用Windows身份验证登录到其计算机,然后转到浏览器中的Web app页面时,他们的用户名应显示在aspx页面上 在服务器上,Windows身份验证设置为true,并且禁用匿名访问 但是,该用户名不会显示在aspx页面上。将显示“欢迎未经验证”。我错过什么了吗?任何指点都很感激 此代码位于SiteMaster.cs中: public partial class SiteMaster : System.Web.UI.
ASP.NET Web应用程序4.0
,并将其移动到服务器上。当用户使用Windows身份验证登录到其计算机,然后转到浏览器中的Web app页面时,他们的用户名应显示在aspx页面上
在服务器上,Windows身份验证
设置为true,并且禁用匿名访问
但是,该用户名不会显示在aspx页面上。将显示“欢迎未经验证”。我错过什么了吗?任何指点都很感激
此代码位于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";
}
}
}
我不知道这是否必须在Web.config
中修改。我没有使用登录功能,因为工作中的任何人都可以访问该页面:
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
尝试将其更改为
<authentication mode="Windows" />
这应该能解决问题