Asp net core randomly restarts under iis


ASP.NET is a popular programming used for building web applications. However, developers may encounter issues with their ASP.NET applications, such as random restarts under IIS (Internet Information Services). In this article, we will explore the possible causes of this issue and provide solutions to resolve it.

Possible Causes

There can be reasons why an ASP.NET Core application randomly restarts under IIS. Let's discuss some of the causes:

1. Configuration Changes

One possible cause is the frequent changes in the application's configuration files. If the application's configuration files are modified frequently, it can trigger an application restart. This can happen when the application's web.config file or any other configuration file is modified, causing the application to restart to apply the changes.

2. File Changes

Another reason for random restarts can be file changes the application's directory. If any file within the application's directory is modified, added, or deleted, it can trigger an application restart. This includes changes to the application's source code files, views, or any other files that are monitored by the ASP.NET runtime.

3. Memory Pressure

Memory pressure on the can also lead to random restarts. If the server's memory exceeds a certain threshold, the ASP.NET runtime may automatically restart the application to free up memory resources. This can happen when the application consumes excessive memory due to memory leaks or inefficient memory management.


Now that we have identified some possible causes, let's discuss the solutions to resolve the random restart issue in ASP.NET Core applications under IIS.

1. Minimize Configuration Changes

To minimize the frequency of application restarts due to configuration changes, it is recommended to consolidate configuration changes and apply them in batches. of frequent individual changes, try to group them together and apply them at once. This will reduce the of restarts triggered by configuration modifications.

2. Use File Change Notifications

ASP.NET Core provides a feature called “File Change Notifications” that allows you to specify which files should trigger an application restart when modified. By configuring this feature, you can exclude certain files from triggering restarts, reducing the chances of random restarts caused by file changes. You can use the ConfigureFileProviderOptions method in the Startup.cs file to configure file change notifications.

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    // Other configuration code


    var fileProviderOptions = new FileProviderOptions
        IgnorePatterns = new[] { "*.txt" } // Exclude .txt files from triggering restarts


    // Other configuration code

3. Optimize Memory Usage

To prevent random restarts caused by memory pressure, it is important to optimize the application's memory usage. Identify and fix any memory leaks in the application code. Implement efficient memory management techniques, such as disposing of resources properly and minimizing the use of large objects. Monitor the server's memory usage and consider upgrading the server's memory if it consistently exceeds the available resources.


Random restarts of ASP.NET Core applications under IIS can be frustrating for developers. However, by understanding the possible causes and implementing the suggested solutions, you can minimize or eliminate this issue. Remember to consolidate configuration changes, configure file change notifications, and optimize memory usage to ensure a stable and reliable ASP.NET Core application under IIS.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents