I\'m getting the below error. This seems to have only started after I upgraded my visual studio 2015 to have the first update. I have read a few threads here about this be
Found a solution to this.
The section of code the error was coming from is the AdalToken.Cache.cs file.
userId = signedInUserId;
this.AfterAccess = AfterAccessNotification;
this.BeforeAccess = BeforeAccessNotification;
this.BeforeWrite = BeforeWriteNotification;
// look up the entry in the database
Cache = db.UserTokenCacheList.FirstOrDefault(c => c.webUserUniqueId == userId);
// place the entry in memory
this.Deserialize((Cache == null) ? null : MachineKey.Unprotect(Cache.cacheBits,"ADALCache"));
Specifically the last line.
Also relevant is the context for the db.UserTokenCacheList which is:
{
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext()
: base("DefaultConnection")
{
}
public DbSet UserTokenCacheList { get; set; }
}
public class UserTokenCache
{
[Key]
public int UserTokenCacheId { get; set; }
public string webUserUniqueId { get; set; }
public byte[] cacheBits { get; set; }
public DateTime LastWrite { get; set; }
}
}
All of this was generated by visual studio when I went through the wizard for setting up Azure authentication when I started this new project.
Regarding the base("DefaultConnection") in the ApplicationDbContext.
There was no entry for this in my web.config, however up until recently this has always worked.
In the web.config, within the < connectionStrings > I added a line for DefaultConnection to point at my database and now it all works, at least for now.
Hope this may be of help to anyone who gets the same error.