Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 959
tungi52 Avatar asked Oct 31 '22 00:10

tungi52


1 Answers

FYI.. This web.config file was missing in the app folder. This file should be at: C:\wwwwroot\myapp\

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath=".\XXX.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
    </system.webServer>
  </location>
</configuration>

Don't forget to replace XXX.exe with the correct name of your Web API exe name.

like image 89
Carlos Cruz Avatar answered Nov 11 '22 14:11

Carlos Cruz