If you try to deploy your ASP.Net Core API files in your live IIS server and receive the following error: HTTP Error 500.19 - Internal Server Error . There are two possible issues that might possibly trigger this problem.
The first possible issue is you may not have installed .Net Core Windows Server Hosting Bundle. This is required and need to be installed on your server. You can download the required software by visiting the following URL.
Once the software has been installed properly, you may have to restart your IIS server.
The second possible issue could be related to permission issue. In your IIS application pool, check the application advanced settings by right click of the selected application pools and select Advanced Settings. See if the framework has been set to No Managed Code and the identity of the application pool has been set to ApplicationPoolIdentity. ASP.Net runs in a separate process and does not rely on loading the CLR. So there is no need to set the .Net CLR version.
Once this is setup correctly, go to your site folder and make sure the permission of the folder grants the user access for the application pool user. The following is an example of screenshot if we have a site and application pool named: local.coreapi.com
Click the edit button and it will popup a window box for you to add a new username or group.Then click the add button.
Enter "IIS AppPool\DefaultAppPool" in the "Enter the object names to select:" text box. (Don't forget to change "DefaultAppPool" here to whatever you named your application pool.)
If you still get the same problem. Try open a command prompt and locate to your ASP.Net core application folder. Then run the following command. Note: mydllfilename is your app dll name. Change this name accordingly.
If it does not work or you get the error message failed to start a process with commandline 'dotnet...'. It means you have not install the .Net Core Windows Server Hosting Bundle correctly or the folder security has not been set properly. If it does work but the IIS does not, then check your web config and see if you need to change the processPath. By default the processPath has value called dotnet. This naming might not be registered on your windows environment. You can manually change the path like below. I use the default program files path. If you have different folder path. Please change it accordingly.
<?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /> </handlers> <aspNetCore processPath="C:\Program Files\dotnet\dotnet.exe" arguments=".\MyApplicationName.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" /> </system.webServer> </configuration>
If this is your first time creating ASP.Net Core Web API, I would highly recommend to check out my article about creating your First ASP.Net Core WebAPI. I have included some explanations and images so you can easily follow the tutorial.
Create your first ASP.Net Core Web API
If you have any question or issue, feel free to post your comment or question below.