Publish dotnet core application to IIS
From Logic Wiki
Prerequisites in IIS server
- Install .NET Core Windows Server Hosting (in almost all of the documents says this is the only thing you need but it’s not)
- Install https://www.microsoft.com/net/download/core runtime (this was the key in our problem even it should be installed with the package above obviously there was something wrong)
if you see 502.5 error this is the solution
- If you see 500.19 error install HTTP Platform Handler
Creating Site in IIS
- Sample screenshot of an imaginary site called MySite is below
- Go To Application Pool and change bindings like below (No Managed Code)
- Go to Advanced settings in application pool and click Identity. Change it to Network Service (it may not be necessary but if you have problem with reading web.config file this is one of the solutions)
Here is a sample web.config file. It must be produced during publish but in some cases API projects don’t produce it. In the absence of web.confg, site returns 404.
If your publish doesn’t have this file, change the red text below with relevant dll name and use it in deployment
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\TestApp.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
<!--ProjectGuid: f0ce46ec-ecbc-4c85-ade9-6210a3e1e8b9-->
HOW TO ADD A CORS COMPLIANT HTTP RESPONSE HEADER TO IIS
In our case we will add the ‘Access-Control-Allow-Origin’ HTTP Response header.
- On the Windows server select the Internet Information Services (IIS) Manager application from the icons in the bottom bar or click the Windows icon and select “Server Manager”
- Navigate to the website you need to edit the response headers for.
- From the list or Icons related to the site you are editing, select “HTTP Response Headers”.
- After it opens look for “HTTP Response Headers”. It will say say, “Use this feature to configure HTTP headers that are added to the responses from the Web server.”
- Click “Add”
- A dialog box will open. For name enter “Access-Control-Allow-Origin” and for Value enter an asterisk. Or, if want to restrict the interactions to queries from a particular site, then enter that domain.
Then click the OK button.

