quick newbie question - Csla.ApplicationContext.User.Identity.Name

quick newbie question - Csla.ApplicationContext.User.Identity.Name

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


griff posted on Tuesday, September 25, 2012

Hi

Enviroment:  Silverlight  app

is this a correct way of using.... (Csla.ApplicationContext.User.Identity.Name)..to update 'createdby' ..or is there a better way.

[Csla.RunLocal]
        protected override void DataPortal_Create()
        {
            LoadProperty(VenueIDProperty, System.Threading.Interlocked.Decrement(ref _lastID));
            LoadProperty(DateNewProperty, DateTime.Now);
            LoadProperty(CreatedByProperty, Csla.ApplicationContext.User.Identity.Name);
            LoadProperty(StatusProperty, "C");
            var args = new DataPortalHookArgs();
            OnCreate(args);
            base.DataPortal_Create();
        }

 

RockfordLhotka replied on Tuesday, September 25, 2012

That should be fine, but it does rely on you having set Csla.ApplicationContext.User to some valid value first.

Silverlight doesn't have any concept of a user identity, so CSLA includes one that matches the .NET principal/identity concept. But because Silverlight doesn't have this concept, you are responsible for setting it to a useful value either as the app starts up or when the user logs into your app.

The 'Using CSLA 4' books have more information on this, especially the 'Data Portal Configuration' and 'WPF and Silverlight' books.

griff replied on Wednesday, September 26, 2012

Very good.  I have managed to set this on login (and re-login) ..whilst it works on my dev machine I just needed to know if it would work once I uploaded to server. Thanks.

Copyright (c) Marimer LLC