4

I developed a web api in asp.net core version 1.0.1 using visual studio 2015, when I published the web api in IIS 10 of the same pc where it was developed, everything works correctly. The problem arises when I copy and paste the publication folder of the web api to a different pc, the browser shows the error 500.19 Internal Server Error, error code 0x8007000d, "The requested page can not be accessed because the related configuration data for the page is invalid ", which leads to some problem in the web.config. I do not think the version of IIS is the problem because moving from IIS 10 to IIS 8 or from IIS8 to IIS 10 gives the same error, and the same happens between two pcs with IIS 10. I have already reviewed several related issues, like, The element 'system.webServer' has invalid child element 'aspNetCore', and others related to web.config file where it seems the error is found. The web.config file in the development environment is:

<?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <!--
    Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
    -->
     <system.webServer>
      <handlers>
       <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
      </handlers>
      <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
     </system.webServer>
    </configuration>

After publish the web api, the web.config file looks like:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!--
    Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
  -->
 <system.webServer>
  <handlers>
   <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
  </handlers>
  <aspNetCore processPath="dotnet" arguments=".\buildingSecureWebApi.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
 </system.webServer>
</configuration>

This web.config file has the same content no matter what computer was publish.

Some idea of ​​what the solution to my problem may be, I need to mount the web api in any version of windows and until now it only works correctly on the pc that was developed.

Lex Li
  • 60,503
  • 9
  • 116
  • 147
Mig
  • 51
  • 1
  • 4
  • 3
    Did you install the .NET Core hosting bundle on the production server and restart it afterwards? – Chris Pratt Feb 28 '18 at 17:35
  • Also, setting `stdoutLogEnabled="true"` in your web.config may help narrow down the issue. – AperioOculus Feb 28 '18 at 20:09
  • Give it up. Redo a project in Visual Studio 2017 before moving on, as you were using obsolete tooling. – Lex Li Feb 28 '18 at 22:55
  • @ChrisPratt I installed .NET Core Windows Server Hosting bundle from [https://aka.ms/dotnetcore-2-windowshosting] and restarted still get the same error **500 Internal Server Error** Any suggestions? – Mig Mar 06 '18 at 02:12
  • @AperioOculus I also tried setting `stdoutLogEnabled="true"` in my web.config but the issue still remains – Mig Mar 06 '18 at 02:16

1 Answers1

11

To get a more detailed error message:

  1. Verify that the log directory exists at the path referenced by the web config. If it does not, create it. The path shown in your config would place the "logs" directory in the root folder of the deployed site.

  2. Verify that the application pool has write access to the logs directory and

  3. Verify that `stdoutLogEnabled="true".

If you have verified all 3 of these items, then you should get log entries that will contain a more detailed description of the error

What could cause a "500.19 Internal Server Error, error code 0x8007000d" error?

  • .NET Core hosting bundle is not installed on the webserver where the site is deployed. To remedy this, obtain this download .NET Core Windows Server Hosting bundle
  • You may also want to verify that the path to the dotnet executable exists in the deployment machine's environment variables. To check this, first find the path where dotnet.exe is installed. It is generally located in either C:\Program Files\dotnet or C:\Program Files (x86)\dotnet. Once you know the path, ensure that the path exists in your Environment Variables.

Control Panel > System > Advanced System Settings > Environment Variables. highlight "Path", click 'Edit' and verify that the path to the dotnet folder is present. If it isn't, add it. Do the same for both the User variables and System variables. Restart your machine and try again.

AperioOculus
  • 6,641
  • 4
  • 26
  • 37
  • I'm giving you an upvote just for finding the download link to the hosting bundle. I've looked and looked and couldn't find it on the downloads page anywhere. – Christopher Painter Mar 24 '18 at 20:26