代码之家  ›  专栏  ›  技术社区  ›  changelog

在模型类中获取用户名

  •  0
  • changelog  · 技术社区  · 17 年前

    日期/时间部分已完成。当属性发生更改时(实现 INotifyPropertyChanging, INotifyPropertyChanged )并且可以很好地更新相应的字段。

    3 回复  |  直到 17 年前
        1
  •  2
  •   Dmitry44    17 年前

    工作得很有魅力。

    我不知道。谢谢。 我这样做:

    Membership.GetUser().UserName
    

        2
  •  2
  •   Community Mohan Dere    9 年前

    this thread

    public static class SomeUtilityClass {
        public static string GetUsername() {
            IPrincipal principal = Thread.CurrentPrincipal;
            IIdentity identity = principal == null ? null : principal.Identity;
            return identity == null ? null : identity.Name;
        }
    }
    ...
    
    record.UpdatedBy = record.CreatedBy = SomeUtilityClass.GetUsername();
    
        3
  •  1
  •   changelog    17 年前

    System.Web 并使用 HttpContext.Current.User.Identity.Name 工作得很有魅力。

    推荐文章