【问题标题】:HttpContex.Current.Profile showing username nullHttpContext.Current.Profile 显示用户名 null
【发布时间】:2012-04-22 19:14:58
【问题描述】:

我正在使用 asp.net 配置文件系统。我在 mASP.NET MVC 中创建了一个名为 CustomProfile 的模型。在这个模型中,我创建了 3 个函数 CreateProfile()、SaveData()、LoadProfile()。

我从 AcountController 的登录操作中调用 LoadProfile(),但问题是当我在 LoadProfile() 函数中使用 HttpContext.Current.Profile 时,它​​显示用户名为空。有什么问题?

【问题讨论】:

  • 是否在 IIS 中为您的网站启用匿名身份验证?
  • 在调用 LoadProfile() 之前用户是否经过身份验证?查看这 3 个函数的代码会很有帮助。

标签: c# .net asp.net-mvc httpcontext asp.net-profiles


【解决方案1】:

需要在 IIS 中的网站/Web 应用程序上启用 Windows 或表单身份验证

【讨论】:

    猜你喜欢
    • 2015-05-11
    • 2011-11-10
    • 1970-01-01
    • 2013-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多