执行该命令需要一个开放且可用的连接。连接的当前状态被破坏

时间:2011-09-13 08:10:15

标签: asp.net sql-server-2008 iis-7

实体框架的严重问题& sql server 2008,请帮忙!! 系统在本地运行良好,但在生产服务器的负载测试期间,我们有超过10个用户的跟随错误。

收到此错误后,用户无法再登录。

'/'应用程序中的服务器错误。 执行该命令需要一个开放且可用的连接。连接的当前状态已被破坏。

这是SQL Server日志

3005
An unhandled exception has occurred.

9/13/2011 3:41:14 AM

9/13/2011 7:41:14 AM

73b3f335f4de45fa8c4ef2f22809300b

4911

482

0

/LM/W3SVC/14/ROOT-3-129603711416579333

Full

/

E:\WebSites\Medtrack2.0\

COLO-VDEV01
15864

w3wp.exe

NT AUTHORITY\NETWORK SERVICE

InvalidOperationException

Execution of the command requires an open and available connection. The connection's current state is broken. at System.Data.Objects.ObjectContext.EnsureConnection() at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable.GetEnumerator() at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source) at Dashboard.Page_Load(Object sender, EventArgs e) at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

http://38.127.112.89:9010/Dashboard.aspx

/Dashboard.aspx

119.148.4.83

JMiranda

True

Forms

NT AUTHORITY\NETWORK SERVICE

11

NT AUTHORITY\NETWORK SERVICE

False

at System.Data.Objects.ObjectContext.EnsureConnection() at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable.GetEnumerator() at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source) at Dashboard.Page_Load(Object sender, EventArgs e) at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

有什么想法吗?

2 个答案:

答案 0 :(得分:4)

答案 1 :(得分:0)

您如何存储ObjectContext?从EF的角度来看,您必须确保每个用户都获得对ObjectContext的唯一引用。为此,我通过将它存储在HttpContext.Current.Items集合中来共享ObjectContext。有关Items集合的更多信息,请参阅此处:http://abhijitjana.net/2011/01/14/when-we-can-use-httpcontext-current-items-to-stores-data-in-asp-net/