我有一個網站運行IIS 7.5 ASP.NET 4使用MySQL連接器6.7.4,我試圖設置它來存儲會話狀態在我的數據庫中。 它可以正常工作(我可以存儲狀態)。但是,當我離開我的瀏覽器打開很長一段時間,然後嘗試刷新頁面,我得到了以下錯誤:MySQL會話狀態提供程序在過期的會話上崩潰
重複項「jouwlxjdufet2fyvf4cwefn2-1」關鍵「主要」
說明:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
異常詳細信息:
MySql.Data.MySqlClient.MySqlException: Duplicate entry 'jouwlxjdufet2fyvf4cwefn2-1' for key 'PRIMARY'
源錯誤:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
堆棧跟蹤:
[MySqlException (0x80004005): Duplicate entry 'jouwlxjdufet2fyvf4cwefn2-1' for key 'PRIMARY']
MySql.Data.MySqlClient.MySqlStream.ReadPacket() +492
MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId) +450
MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) +136
MySql.Data.MySqlClient.MySqlDataReader.NextResult() +1121
MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) +2648
MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() +140
MySql.Web.SessionState.MySqlSessionStateStore.CreateUninitializedItem(HttpContext context, String id, Int32 timeout) +553
[ProviderException: An exception occurred. Please check the event log.]
MySql.Web.SessionState.MySqlSessionStateStore.HandleMySqlException(MySqlException e, String action) +281
MySql.Web.SessionState.MySqlSessionStateStore.CreateUninitializedItem(HttpContext context, String id, Int32 timeout) +709
System.Web.SessionState.SessionStateModule.GetSessionStateItem() +304
System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +1076
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +115
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1008
我的web.config包含以下
<system.web> <sessionState mode="Custom" cookieless="false" regenerateExpiredSessionId="false" customProvider="MySqlSessionStateProvider" timeout="20"> <providers> <add name="MySqlSessionStateProvider" type="MySql.Web.SessionState.MySqlSessionStateStore, MySql.Web, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" applicationName="/skygdadmin" description="" connectionStringName="MySqlServer" writeExceptionsToEventLog="False" autogenerateschema="True" enableExpireCallback="True" /> </providers> </sessionState> ...
我可以在數據庫中看到了已經存在的項目:
表:my_aspnet_sessions
SessionId: 'jouwlxjdufet2fyvf4cwefn2'
ApplicationId: '1'
Created: '2013-08-22 08:29:34'
Expires: '2013-08-22 09:49:39'
LockDate: '2013-08-22 09:29:39'
LockId: '419'
Timeout: '20'
Locked: '0'
SessionItems: [lots of stuff]
Flats: '0'
此外我可以看到,my_aspnet_sessioncleanup表定期更新,指示會話清理正在運行(每10分鐘)。
有沒有人有從哪裏開始調試的任何想法? 謝謝 大衛
你發現了什麼造成的?我有同樣的問題... – Ami
不,我沒發現,這是我完全停止使用MySQL連接器作爲會話狀態提供程序。我前往亞馬遜,發現他們的DynamoDB會話狀態提供者像魅力一樣工作。 – DavKa