Search code examples
c#asp.net-coreiis-7.5

ASP.NET Core page not found when publishing to IIS


I updated my ASP.NET Core project from RC1 to 1.0 RTM (with preview2 tooling), everything went fine. I can debug in Visual Studio without problems. Next I would like to upload the site on a Windows Server 2008 R2 and IIS 7.5. I installed the necessary Windows Hosting tools and created the web application in the IIS. The problem is, that after I tried to open the page, it returned a 404 error. As I see in the task manager, my application is running, but stops in listening mode.

In the log file I only see these entries:

Hosting environment: Production
Content root path: C:\inetpub\wwwroot\MySite
Now listening on: http://localhost:20706
Application started. Press Ctrl+C to shut down.

It seems like there is some problem with the IIS integration. My web.config file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="..\..\approot\MySite\MySite.exe" arguments="" forwardWindowsAuthToken="true" stdoutLogEnabled="true" />
    <httpErrors errorMode="Detailed" />
  </system.webServer>
</configuration>

I tried some workarounds from GitHub, which affected the Startup.cs file's Configure method without any success.

Any ideas?


Solution

  • Ok, I had multiple problems, but the two main reasons why my site didn't work:

    1. I cannot start the code from two separate places. I originally put the wwwroot content under the wwwroot folder (not so suprising), and the rest to the approot. Now everything should be in the same folder.
    2. My release versions didn't want to work. I must use the contents of the debug folder. I don't know why.

    And now, everything is ok.