NullReferenceException in MSALSessionCache constructor
ckarras opened this issue · 1 comments
ckarras commented
In the latest version from the master branch, MSALSessionCache is no longer used but has been replaced by MSALStaticCache. However, if I modify the code to switch back to MSALSessionCache, there is a NullReferenceException in the Load() method called from the constructor, because the "cache" variable is null at this point:
public void Load()
{
SessionLock.EnterReadLock();
byte[] blob = httpContext.Session.Get(CacheId);
if(blob != null)
{
cache.DeserializeMsalV3(blob);
}
SessionLock.ExitReadLock();
}
This is how I create the MSALSessionCache (instead of MSALStaticCache):
new MSALSessionCache(signedInUserID, this.HttpContext).EnablePersistence(cca.UserTokenCache);
If I use MSALStaticCache as a reference, I see Load() should not be called from the constructor, but should be called from EnablePersistence instead
TiagoBrenck commented
Fixed