【问题标题】:Application won't read username on IIS应用程序不会在 IIS 上读取用户名
【发布时间】:2013-09-23 11:46:18
【问题描述】:

我有这个应用程序,我通过 PC 用户登录。我正在使用这个:

public static bool IsAuthenticated()
{
    if (HttpContext.Current.User.Identity.IsAuthenticated)
    {
        CurrentUser = Factory.Users.List(item => item.Username.ToLower() == cToLower()).FirstOrDefault();
    }

    return CurrentUser != null;
}

注意:.List() 是我创建的用于列出所有数据库用户的方法(在 本例)。

一切正常。但是当我在我的 IIS 上发布我的网站时,HttpContext.Current.User.Identity.Name 什么也没有返回,根本没有用户。它有什么问题?有什么建议吗?

【问题讨论】:

标签: c#


【解决方案1】:

您必须启用 IIS Windows Authentication拒绝 Annomyous acces。您可以按如下方式配置 IIS 或更新配置文件,

<configuration>
  <system.web>
    <authentication mode="Windows" />
         <authorization>
             <deny users="?"/>
          </authorization> 
    </system.web> 
</configuration>

【讨论】:

    猜你喜欢
    • 2016-07-07
    • 1970-01-01
    • 2012-02-06
    • 2014-10-01
    • 1970-01-01
    • 2021-08-28
    • 1970-01-01
    • 2012-11-19
    • 1970-01-01
    相关资源
    最近更新 更多