HTTP status code 500 (Internal Server Error) points to a range of issues from coding to configuration. Failed Request Tracing (FREB) comes to help to determine the underlying issue which was AspNetInitClrHostFailureModule with 0x80131704 error code (2148734724) in this case.
The full error message from the FREB log:
An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur.
HttpReason: Internal Server Error
This issue started occurring after migrating the application from Windows Server 2008 R2 to Windows Server 2012 R2.
Root cause of 0x80131704 error (2148734724)
The error code 2148734724 translates to 0x80131704 in HEX (Use Windows Calculator in Programmer mode to calculate this value).
0x80131704 HEX code means: “A different runtime was already bound to the legacy CLR version 2 activation policy” (Reference).
As the error message mentions, there is a conflict with the runtime version IIS is trying to use to run the application. Either web.config or another mechanism is forcing the application to run on an unsupported .NET framework version.
In my case, it was w3wp.exe.config (Located in C:\Windows\SysWOW64\inetsrv\). There was this line at the end of the file:
This is what caused the issue. The application was developed to run on .NET Framework 4.0 or a newer version. However, the config line above forced IIS to run this application on .NET Framework 2.0.
Solution for 500 Internal Server Error related to AspNetInitClrHostFailureModule
We removed the
supportedRuntime line (full line is above) from the w3wp.exe.config in C:\Windows\SysWOW64\inetsrv\ folder. Then restarted IIS. The application started working afterwards.
Note: This issue surfaced with “Unrecognized attribute ‘targetFramework’” message first. It was complaining about the
compilation targetFramework="4.5" line in the web.config. Event Viewer showed “The application has reported as being unhealthy. The worker process will now request a recycle. Reason given: An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur. The data is the error.” message. Removing
targetFramework line from the web.config revealed the actual issue which I described above (More about targetFramework error).
If you have tried this solution already but still seeing the 0x80131704 error, please check the posts below for other causes and solutions of the 500 Internal Server Error issue:
- 500.19 Internal Server Error (0x8007000d)\
- 500 Internal Server Error if the full path is not entered (0x80070542)
- HTTP Error 500.30 – ANCM In-Process Start Failure (Solved)
- Prevent settings to be overridden by web.config (HTTP Error 500.19)
- IIS logs 500.19 if a client drops connection while loading the website
- WordPress 500 Internal Server Error