如何保持在AppDomain中ASP.NET组件还活着吗? [英] How to keep ASP.NET assemblies in AppDomain alive?

查看:185
本文介绍了如何保持在AppDomain中ASP.NET组件还活着吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情景:我一直在使用Web部署项目部署n层的企业ASP.NET应用程序。所有层产生由ASP.NET应用程序所消耗的独立组件。

Scenario: I've an n-Tier enterprise ASP.NET application deployed using Web Deployment Projects. All tiers produce independent assemblies that is consumed by the ASP.NET application.

问题::当我运行应用程序。部署后的第一次所花的时间很多内存来加载依赖程序集。但是,一旦加载其照明快速应用。在情况下,如果没有用户访问应用程序,IIS从内存中卸载的组件,并在用户试图访问它继续加载所有组件再次以相同的时间量来加载,因为它后面的实例中的应用花费首次这样做。

Problem: When I run the app. for the first time after deployment it takes lot of time to load dependent assemblies in memory. But once loaded its lighting fast app. In case if there are no users accessing the app, IIS unloads the assemblies from the memory and when a user tried to access the app on a later instance it goes on loading all the assemblies once again taking the same amount of time to load as it takes to do so for the first time.

我正在寻找一个解决方案,使我保持组件加载到内存中坚持重写组件对内存驻留的波动性。

或任何其他解决方案,让我的用户愉快地使用应用程序解决了上述问题。

Or any other solution that lets my users happily use the app resolving the mentioned problem.

推荐答案

IIS 6 ,转到应用程序池部分,并用鼠标右键单击>属性上承载ASP.NET池应用程序有问题。转到性能选项卡和在空闲后关闭工作进程:取消

In IIS 6, go to the Application Pools section, and right-click > Properties on the pool which hosts the ASP.NET application in question. Go to the Performance tab and uncheck "Shutdown worker processes after being idle for:"

IIS 7 ,进入连接窗格中,找到应用程序池,然后选择高级设置它承载您的应用程序池。找到空闲超时属性,并将其设置为0(这将禁用它)。

In IIS 7, go to the Connections pane and find Application Pools, and select Advanced Settings for the pool which hosts your application. Find the "Idle Timeout" property and set it to "0" (this disables it).

默认为20分钟不活动。取消选中该复选框,一旦你的的AppDomain 被加载的<一个href=\"http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/29f53968-0115-451f-b26d-5ad58d87b5d1.mspx?mfr=true\">worker过程,它永远不会死(除非你杀掉进程或课程的东西)。默认情况下,IIS将<一个href=\"http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/24e3c22e-79a9-4f07-a407-dbd0e7f35432.mspx?mfr=true\">recycle过程当它达到一定的限制,例如,存储器盖,但直到旧的是未使用的,以最小化破坏它还将启动过相所有传入请求一个新的和

The default is 20 minutes of inactivity. By unchecking the box, once your AppDomain is loaded by the worker process, it will never die (unless you kill the process or something of course). By default, IIS will recycle the process when it reaches some limit, such as a memory cap, but it will also start a new one and "phase over" all incoming requests until the old one is unused, so as to minimize disruption.

我也写了一个小的C#类将保持你的ASP.NET应用程序还活着(<一个href=\"http://web.archive.org/web/20100213092317/http://www.rexmorgan.net/journal/fixing_aspnet_ldquokeep\">alternate存档版本)在正常情况下。由于它的应用程序内运行,显然它不能从明确杀死进程停止IIS或其他任何东西,但它会保持应用的热,例如该应用程序将永远不会闲置足够长IIS决定关闭它。

I've also written a small c# class which will keep your ASP.NET application alive (alternate archived version) under normal circumstances. Since it runs within the application, obviously it can't stop IIS or anything else from explicitly killing the process, but it will keep the application "hot", e.g. the app will never go idle long enough for IIS to decide to shut it off.

如果你没有在你的IIS配置的直接控制(共享主机,例如)最好的办法是有一个单独的系统上运行的一个小应用程序 - 例如,一个始终保持接通工作站 - 这击中了你的网站每x分钟,以保持应用程序池超时。没什么特别 - 一个简单的的WebRequest 并在控制台应用程序中的while()循环就行了。

If you do not have direct control over your IIS configuration (shared host, for example) your best bet is to have a small application running on a separate system - say, an always-on workstation - which hits your site every x minutes to keep the application pool from timing out. Nothing fancy - a simple WebRequest and a while() loop in a console application will do.

这篇关于如何保持在AppDomain中ASP.NET组件还活着吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆