Blazor Server and Application Context #2595
Replies: 1 comment 3 replies
-
Hi @mikeclimbs23 - unfortunately this is a known issue with SSB and CSLA 5. The fix (major rewrite really) is coming in CSLA 6. The reason the solution is major, is that unlike all .NET frameworks to date, server-side Blazor does something new and interesting: using a dependency injection scope for isolation between user sessions on the server. In the past, things like the user identity and other state were maintained using thread-local storage or (in aspnet) HttpContext. Those ambient values can be accessed via static code such as In server-side Blazor (not Blazor wasm, which works "like normal"), the only way to get things like the current user identity, or to maintain state, is to use a scope-level service injected via DI. As it is impossible to inject values into static code, the entire concept of the static methods on ApplicationContext has become unworkable. So CSLA 6 now has an instance of ApplicationContext that is a service, and it is injected into your code when necessary. There is (and won't be) a fix in CSLA 5, because these changes are substantial and therefore are breaking to all existing code. We use semantic versioning, so breaking changes require a major version change - hence the "fix" (new feature?) is coming in CSLA 6. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm using CSLA 5.5 with blazor server. I store the database name in the applicationContext.GlobalContext. Csla.ApplicationContext.GlobalContext.Add("Database", DatabaseName);
In bizoject validation, I load a bizobject to check validation meets certain user-definable rules. I'm loading the bizobject using the code below.
CO_CompanyInfo CompanyInfo;
CompanyInfo = Csla.DataPortal.Fetch<FezWeb.BizObj.CO_CompanyInfo>(0)
When the bizobject company info reads the globalcontext the key is missing. I'm guessing I'm not instantiating the biz object correctly and that's why it's referencing an empty ApplicationContext. Any pointers would be appreciated.
Thanks,
Mike
Beta Was this translation helpful? Give feedback.
All reactions