IIS app pool recycling randomly every few seconds
IIS app pool recycling randomly every few seconds
You don't have to incur overhead to add custom logging, ASP.NET 2.0 health monitoring does the job for you. You can add the following configuration which will log events in the eventlogs with information why Application pool is restarted.
To turn ASP.NET health monitoring ON, you can edit the "master" web.config
file, normally found in %systemroot%\microsoft.net\framework\v2.0.50727\config
.
-
First, look for
<healthMonitoring>
in the masterweb.config
-
Inside the
healthMonitoring
node, find the<rules>
node -
Inside rules, add the following:
<add name="Application Lifetime Events Default" eventName="Application Lifetime Events" provider="EventLogProvider" profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:01:00" custom="" />
Reproduce the issue and look in the Application event log fpr a source of ASP.NET 2.0. This should log why application pool is recycled.
逐条查看event log里面的信息,注意event code的不同,比如1002和1003
发现这个提示信息,
Event code: 1002
Event message: Application is shutting down. Reason: A subdirectory in the Bin application directory was changed or renamed.
Event time: 29/03/2022 13:13:14
Event time (UTC): 29/03/2022 12:13:14
Event ID: f122178201b44afebff56d69425e4cba
Event sequence: 1
Event occurrence: 1
Event detail code: 50007
Change Notification for critical directories
Symptoms
When the end users execute any action in their Work Portal, the application redirects them to the Start page.
The Administrator user identifies that the Application is constantly restarted and the Application Server Log Viewer records the following error:
CauseThe Framework finds changes in the bin directory and restarts the application. |
SolutionFirst, validate that your server does not have viruses or another agent that can possibly change the bin directory. Review your Antivirus configuration and perform a general check on the server. If the server is virus-free and there is no external agent making changes in the bin directory, perform a change in the Windows Registry of your server. To do this, follow the instructions below: 1. Take a backup of the Windows Registry:
1.1. Click the Start button, click Run, and type REGEDIT. Click OK.
1.2. In the Registry Editor, select the HKLM\Software\Microsoft\ASP.NET\ branch. 1.3. From the Registry menu, choose Export Registry File. 1.4. In the Save In list, select the folder where you want to save the backup. 1.5. In the File Name box, type a name for your backup file, such as "Options" or "Backup." 1.6. In the Export Range box, be sure that "Selected branch" is selected. 1.7. Click Save. The file is saved with a .reg extension.
2. Create the FCNMode key with type DWORD and value 1 in the branch HKLM\Software\Microsoft\ASP.NET\ 2.1. Select the branch HKLM\Software\Microsoft\ASP.NET\.
2.2. Right-click on the entry and select New DWORD (32bit) value. 2.3. Put the name FCNMODE. 2.4. Right-click on the key FCNMODE and select Modify. 2.5. In the Value data box, set 1.
2.6. Exit Registry Editor. |
https://docs.microsoft.com/en-us/dotnet/api/system.web.configuration.fcnmode?view=netframework-4.8
Default | 1 |
For each subdirectory, the application creates an object that monitors the subdirectory. This is the default behavior. |
Disabled | 2 |
File change notification is disabled. |
NotSet | 0 |
File change notification is not set, so the application creates an object that monitors each subdirectory. This is the default behavior. |
Single | 3 |
The application creates one object to monitor the main directory and uses this object to monitor each subdirectory. |
ASP.NET MVC app restarts itself
You need to figure out what is touching the hash.web file: a likely cause is a virus scanner. Monitor the file with Process Monitor.
If possible, exclude the Temporary ASP.NET Files directory and subdirectories from automatic virus scanning as well as the web content directories.
In .NET 2.0 it is possible to disable FileChangesMonitoring through the HKLM\Software\Microsoft\ASP.NET\FCNMode key, a value of 1 will disable file change monitoring. The drawback of disabling this is that if you disable it, the application will not restart if you change web.config etc.
Of Interest: ASP.NET File Change Notifications, exactly which files and directories are monitored?
WebHost failed to process a request.
Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/57073498
Exception: System.ServiceModel.ServiceActivationException:
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2020-03-29 The What, Why, and How of a Microservices Architecture
2020-03-29 解析“60k”大佬的19道C#面试题
2019-03-29 UML类图中箭头的含义
2019-03-29 .NET Standard vs. .NET Core
2019-03-29 FileAttributes Enum
2016-03-29 单元测试实战
2016-03-29 如何查看单元测试的结果 以及异常处理