为什么我的新的.NET 4.0 EF应用随机锁定?我的、NET、EF

2023-09-04 00:27:21 作者:念你成痴

我最近推出了一个新的ASP .NET应用程序。此应用程序使用的.Net 4.0和实体框架4。这是一个基本的CRUD应用程序。我几乎只使用EntityDataSource的数据访问。

I have recently rolled out a new ASP .Net application. This application uses .Net 4.0 and the Entity Framework 4. It is a "basic" CRUD application. I almost exclusively used the EntityDataSource for Data Access.

在用户报告应用程序(它们都使用IE 8)的ocassional冻结。如果用户关闭浏览器,并开始回涨,该应用程序是好的。它可能会发生一次或两次,每天总,平时的重度使用者。 (所以,我一直倾向于记忆leack或一些其他类型的资源限制。)

The users have reported "ocassional freezing" of the application (they all use IE 8). If the user closes his browser and starts back up, the app is fine. It happens maybe once or twice per day total, usually to the heavy users. (So, I have been leaning toward memory leack or some other kind of resource limitation.)

直到只是一小会儿前,我从来没有看到这种情况发生。它不到风度客户端PC,也没有服务器上保留在事件日志中任何东西。此外,没有什么在IIS错误日志或SQL日志。

Until just a little while ago, I have never seen this happen. It dosn't leave anything in the Event Log on the client PC nor Server. Also, there is nothing in the IIS error logs or the SQL logs.

不久之前,我终于得到了它发生。我交换了我所有的EntityDataSources使用每页一个对象上下文。我下载了EF探查器(这似乎是一个伟大的产品),并指出,我使用我的很多页多目标环境中,由于这样的事实,其中许多人有一个以上的EntityDataSource。所以,我是清理这一切和测试每个页面,当你瞧.... IE浏览器停止加载网页!

A little while ago, I finally got it to happen. I was switching all of my EntityDataSources to use a single Object Context per page. I downloaded the EF Profiler (which seems to be a great product) and it pointed out that I am using multiple object contexts on many of my pages, due to the fact that many of them have more than one EntityDataSource. So, I was cleaning all this up and testing each page, when lo and behold....IE stopped loading pages!

起初,页面开始加载慢(这是我已经修改为使用一个单一的对象上下文的网页,所以虽然我仍然认为我需要实现整个所有的页面这个单的模式,我想它是不是罪魁祸首反正..),那么在某些时候我收到了!

At first, the page started loading slowly (and this was a page that I had already modified to use a single Object Context, so although I still believe I need to implement this "singleton" pattern throughout all my pages, I guess it isn't the culprit! Anyway..), then at some point I received:

消息:Sys.WebForms.PageRequestManagerTimeoutException:服务器请求超时

Message: Sys.WebForms.PageRequestManagerTimeoutException: The server request timed out.

不过,没有在事件日志中。我还检查了IIS网络日志,我看不到任何东西,但他们是pretty的很难看用肉眼,我可能要下载一个分析器,以确保没有任何在那里。

Still, nothing in the Event Log. I also checked the IIS web logs and I don't see anything, but they are pretty tough to read with the naked eye, I may have to download a parser to make sure there is nothing in there.

反正,我决定开始另一个窗口并导航到我的应用程序,果然那个窗口工作得很好,没有任何问题。我又回到了停止响应的窗口,刷新它,等待着......跑到我的应用程序的主页(这基本上只是一些静态html​​ ..并没有什么..)。接下来,我在当前冻结窗口中打开一个新的标签,而标签工作正常。所以,我回去,可以从我的应用程序不再加载页面,并尝试一些其他网站的窗口.... espn.com加载罚款,msn.com加载罚款,我然后输入网址我的应用程序的主页(并试图在我的应用程序的一些其他网页)并没有什么。 IIS甚至不登录其日志文件的尝试(它就像IE浏览器刚刚决定不办了获得我的本地主机!)。最后,等了一会(虽然我打字这个职位)后,我现在在该窗口中此错误消息:

Anyway, I decided to start up another window and navigate to my app, and sure enough that window worked fine, no problems. I went back to the windows that stopped responding, refreshed it, waited... went to the home page of my app (which is basically just some static html.. and nothing.. ). Next, I opened a new tab in the window that is currently frozen and that tab works fine. So, I go back to the window that can no longer load pages from my app and try some other web sites.... espn.com loads fine, msn.com loads fine, I then enter the URL for my app home page (and tried some other pages in my app) and NOTHING. IIS doesn't even log the attempts in its Log Files (its like IE has just decided not to do anymore "gets" for my localhost!). Finally, after waiting for a while (while I was typing this post) I now have this error message in that window:

Internet Explorer无法显示该网页。什么,你可以尝试:这个问题可以通过各种各样的问题造成的,其中包括:BLAH BLAH BLAH ...

Internet Explorer cannot display the webpage. What you can try: The problem can be caused by a variety of issues, including: BLAH BLAH BLAH...

所以,我跳回到那个窗口,它仍然可以浏览互联网网站就好了。但是,再一次当我尝试去任何我的应用程序的网页,我什么也得不到(纺蓝色圈中的标签)。于是,我再次开始在同一个浏览器的新选项卡,我可以在我的应用程序浏览就好了。

So, I jump back to that window and it can still browse Internet sites just fine. But, once again when I try to go to any of the pages in my app, I get NOTHING (spinning blue circle in the tab). So, once again I start a new tab in that same browser and I can browse around my application just fine.

什么是我的应用程序做,将不再让它加载任何网页这个浏览器实例(事实上,它看起来像它甚至没有做任何的应用程序页面的GET,因为有新意在IIS日志...除了当我加载在这些其他选项卡和/或做工精细浏览器窗口的页面,所以记录仍在工作......)?我将永远感激,可以帮助我想出解决办法的人。我不知道它会做的多好,但我要离开这个浏览器窗口上的机会,有人能告诉我一些事情来尝试诊断此问题。这感觉就像我是如此接近计算出来。我终于有一个窗口开始,直到被行为不端。恐怕关闭窗口或做一个新的构建上的应用程序,直到我得到的东西去尝试一些好的输入......

What has my app done to this browser instance that will no longer let it load any of its pages (in fact, it seems like it isn't even doing a GET on any of the apps pages, since there is nothing new in the IIS logs...except for when I load the pages in these other tabs and/or browser windows that work fine, so the logging is still working...)? I will be forever indebted to the person that can help me figure this out. I am not sure it will do much good, but I am going to leave this browser window up on the chance that someone can tell me some things to try to diagnose this problem. It feel like I am THIS close to figuring it out. I finally have a window up that is misbehaving. I am afraid to close the window or do a new build on the app until I get some good input on things to try....

我要补充一点,当这发生在我身上,我被我的本地PC上运行,所以我是唯一的用户,并只有一个窗口开放的应用程序。

I should add that when this happened to me, I was running on my local PC, so I was the only user and only had one window open to the app..

虽然,我彻底难倒!

推荐答案

我们有同样的问题,似乎通过添加以下JavaScript来的所有页面使用Ajax来解决它:

We had the same issue and seemed to fix it by adding the following JavaScript to all pages with ajax:

window.onunload = abortRequest;
function abortRequest() {
   Sys.WebForms.PageRequestManager.getInstance().abortPostBack();
} 

我希望这有助于!

I hope this helps!