We just migrated from the older ASP.NET membership (from MVC3) to the new ASP.NET universal providers since our SQL target is Azure SQL. The SQL scripts during that move were - painful! Anyway, we set session state to SQL (i.e. <sessionState mode="Custom"
in web.confg).
Now if the site goes down unexpectedly, (say debugging => stop) when we resume we get the error:
Violation of PRIMARY KEY constraint 'PK__Sessions__C9F492908756A0EE'. Cannot insert duplicate key in object 'dbo.Sessions'. The duplicate key value is (<randomstring>).
The statement has been terminated.
As expected, I confirmed that the session does indeed have the same entry in the db inside the [db].[SessionId]
table with the primary key.
Question: Who is responsible for deleting that db entry? I understand if a logout is properly initiated it should get wiped out by code. But shouldn't there be some automatic error handling (in Memberships itself) in case it already exists? If yes, why isn't it triggered? If no, how can I add it?