我有一个使用 MySQL 连接器 6.7.4 在 IIS 7.5 ASP.NET 4 中运行的站点,我正在尝试将其设置为在我的数据库中存储会话状态。开始时效果很好(我可以存储状态)。但是当我长时间打开浏览器然后尝试刷新页面时,我收到以下错误:
键 'PRIMARY' 的重复条目 '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"> <供应商> <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" /> </提供者> </会话状态> ...
我可以在数据库中看到已经存在的条目:
表: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 分钟一次)。
有人对从哪里开始调试有任何想法吗?谢谢大卫