Context Issue

Context Issue

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


bnair posted on Friday, August 04, 2006

Hi All,

I am using CSLA to build an application.My database table has a column createdBy and I need to get the logged in user in the Business Object.I dont want the user to set it rather I want the BO to read for the current context.

Here is the code I have in the web app membership provider

public override bool ValidateUser(

string username, string password)

{

bool result = PEPrincipal.Login(username, password);

HttpContext.Current.Session["CslaPrincipal"] = Csla.ApplicationContext.User;

//Csla.ApplicationContext.ClientContext.Add("user_id", 123);

return result;

}

How do I access this in the BO ?

I tried teh following but its giving me an invalid cast exception

//PEPrincipal _principal;

//_principal = (PEPrincipal)Csla.ApplicationContext.User;

//PEIdentity _identity = (PEIdentity)_principal.Identity;

Any suggestions ?

Also can anyonw suggest me how to use the ClientContext ?

--bnair

 

RockfordLhotka replied on Friday, August 04, 2006

The basic flow is discussed in Chapter 10. You need to reload the principal on every page request - typically in global.asax.

Copyright (c) Marimer LLC