Keywords: HTTP Error 500.31 | ASP.NET Core | IIS Deployment | Application Pool Permissions | .NET Core Runtime
Abstract: This article provides an in-depth analysis of the common HTTP Error 500.31 encountered when deploying ASP.NET Core applications on IIS. By systematically examining error messages in the Event Viewer, it focuses on application pool permission configuration as a key factor and offers detailed diagnostic steps and solutions. Combining multiple real-world cases, the article covers various scenarios that may cause this error, from permission settings and runtime installation to configuration file checks, helping developers quickly identify and resolve issues.
Problem Overview
When deploying .NET Core applications on IIS in Windows 10 systems, many developers encounter HTTP Error 500.31 - Failed to load ASP.NET Core runtime. This error is typically accompanied by three key error messages in the Event Viewer: inability to locate application dependencies, failure to find the aspnetcorev2_inprocess.dll file, and application startup failure.
In-depth Analysis of Error Symptoms
From the error messages in the Event Viewer, the system indicates that it cannot find the required dependencies for Microsoft.NetCore.App and Microsoft.AspNetCore.App versions. Superficially, this appears to be a missing runtime environment issue, but the actual situation is often more complex. Notably, in some cases, even when the correct .NET Core runtime is installed on the system and other applications of the same version run normally, newly deployed applications still experience this error.
Core Solution: Application Pool Permission Configuration
Based on best practice cases, the root cause of this problem often lies in insufficient access permissions of the application pool to the site folder. When the IIS application pool's identity lacks adequate permissions to read and execute application files, it results in runtime load failure.
To resolve this issue, follow these steps:
- Open Windows Explorer and navigate to the website file directory
- Right-click the folder and select "Properties"
- Go to the "Security" tab
- Click the "Edit" button to add new permissions
- Click "Add" and enter the identity used by the application pool (typically IIS AppPool\ApplicationPoolName)
- Grant "Read & execute", "List folder contents", and "Read" permissions to this identity
- Click "OK" to save the settings
Other Potential Causes and Solutions
Missing ASP.NET Core Hosting Bundle
In some cases, the problem indeed stems from missing ASP.NET Core runtime environment. Ensure that the corresponding version of ASP.NET Core Hosting Bundle is installed on the target machine, not just the runtime environment. The Hosting Bundle includes IIS modules and support components, which are essential for hosting ASP.NET Core applications in IIS.
32-bit Application Settings
The "Enable 32-Bit Applications" setting in the application pool can also cause this issue. If the application is compiled for 64-bit architecture but the application pool has 32-bit support enabled, compatibility issues arise. Check the advanced settings of the application pool in IIS Manager to ensure this setting matches the application's target architecture.
web.config Configuration File Errors
The aspNetCore configuration section in the web.config file must correctly point to the project's DLL file. Ensure that the path and filename in the arguments attribute match the actually published files. For example: <aspNetCore processPath="dotnet" arguments=".\YourProject.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="inprocess">
Systematic Diagnostic Approach
To accurately identify the root cause, adopt the following systematic diagnostic process:
- Enable stdout logging by setting stdoutLogEnabled="true" in web.config
- Check detailed error messages in the Event Viewer
- Verify runtime environment using dotnet --info command
- Test application functionality from the command line
- Validate folder permission settings
- Check application pool configuration
Preventive Measures
To prevent recurrence of similar issues, incorporate the following checkpoints into the deployment process:
- Establish standardized permission configuration templates
- Integrate environment verification steps into CI/CD pipelines
- Maintain deployment checklists including runtime versions, permission settings, and other critical items
- Use configuration management tools to ensure environment consistency
Conclusion
Although HTTP Error 500.31 presents with a single manifestation, its underlying causes may involve multiple aspects including permission configuration, runtime environment, and application settings. Through systematic diagnostic methods and targeted solutions, developers can effectively address this common deployment challenge, ensuring stable operation of ASP.NET Core applications in IIS environments.