Re: Csla.ApplicationContext.User.Identity error CSLA.net 3 & 4

Re: Csla.ApplicationContext.User.Identity error CSLA.net 3 & 4

Old forum URL: forums.lhotka.net/forums/t/10010.aspx


JonnyBee posted on Tuesday, February 01, 2011

Which client platform and CSLA version are you using?

Do you use the standard System.ComponentModel.BackgroundWorker in your application?
If you are then switch to use Csla.Threading.BackgroundWorker.

The most likely cause is that you are on another thread:

    public static IPrincipal User
    {
      get
      {
        IPrincipal current;
        if (HttpContext.Current != null)
          current = HttpContext.Current.User;
        else if (System.Windows.Application.Current != null)
        {
          if (_principal == null)
          {
            if (ApplicationContext.AuthenticationType != "Windows")
              _principal = new Csla.Security.UnauthenticatedPrincipal();
            else
              _principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
          }
          current = _principal;
        }
        else
          current = Thread.CurrentPrincipal;
        return current;
      }

 

 

Copyright (c) Marimer LLC