0
votes

Built a default Net Core 2 app w/no authorization and successfully web-deployed via VS2017 Publish to remote IIS instance under Win 7. However, the app fails to run, generating an HTTP 500 error.

Log file shows a 500.19 error:

Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken 2018-03-29 20:42:20 ::1 GET / - 81 - ::1 Mozilla/5.0+(Windows+NT+6.1;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko 500 19 5 296

After researching, there seems to be a myriad of options for setting up to run under IIS. I first tried MS recommendations, which resulted in above error.

Here is web.config:

 <?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=".\WebApplication1.dll" 
                stdoutLogEnabled="true" 
                stdoutLogFile=".\logs\stdout" />
  </system.webServer>
</configuration>

Here is IIS site configuration:

enter image description here

IIS add-ins:

  1. MS Web Platform Installer

  2. Net Core Server Hosting

  3. Web Deploy

  4. MS .NET Core 2.0.6 Windows Server Hosting

Questions:

  1. should a default app work as is when published to IIS?
  2. If not, what is necessary?
2
When you checked the event log (with Event Viewer) was there anything interesting there?mjwills
Did you install the .NET Core Server Hosting Bundle? It won't work with an OOB IISCamilo Terevinto
Yes, bundle is installed. See above to see installed packages.JJJulien
The actual 500.19 page would tell what is the cause. Try every way to find it.Lex Li

2 Answers

2
votes

The solution was adding IIS Application Pool access rights to the folder holding the Net Core app as shown here in the Microsoft documentation.

So, yes, a default ASP.NET Core 2 app will run fine under IIS as is. Problem had nothing do with application at all.

Since this problem cost me almost three days of my life due to ignorance of web development and IIS specifically, I will post this answer in case someone else has the same problem.

Thank you Simonare for sending me down the right track, albeit indirectly.

1
votes

This doesnt show enough information about error.

First thing first I suggest you to enable stdoutLog under web.config. And It also make sense to enable detailed error logs under program.cs by including UseSetting("detailedErrors", "true") CaptureStartupErrors(true)

var host =  WebHost.CreateDefaultBuilder(args)
        .UseSetting("detailedErrors", "true")
        .CaptureStartupErrors(true)
        .UseKestrel()
        .UseStartup<Startup>()
        .Build();

furthermore you can try to run dotnetcore application on server by opening command prompt on the deployment directory and running application with executing `dotnet yourApplicatonName.dll

further troubleshooting information can be found below

https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/troubleshoot

EDIT: When you publish your application it sometimes need to publish your application by targetting remote operation system version. For this you need to include RuntimeIdenfiers in your project.csproj

<RuntimeIdentifiers>win10-x64;win7-x64</RuntimeIdentifiers>

Catalog of the runtime identifiers can be found in https://docs.microsoft.com/en-us/dotnet/core/rid-catalog

then you need to update your publish profile to target remote platform correcly. By Default, It is "Portable"