Hosting ASP.NET Core to IIS returns Internal Server error

0

Deployed ASP.NET MVC Core 1.1.1 on Windows 2012 Server R2. Followed this ASP.NET article (installed DotNetCore.1.0.5_1.1.2-WindowsHosting bundle etc). App runs fine as localhost on the server if we follow the following steps:

  1. In cmd from root dir of the app, ran: dotnet MyWebapplication.dll
  2. Noticed that application is running and waiting for responses on localhost:5000.
  3. Opened the browser on the host server and navigated to: http://localhost:5000
  4. Home page opened as expected But when we navigate to the http://IP Address/MyWebapplication on a different desktop on the same network, we get the 500 - Internal Server Error

NOTE: We tested that if we host a simple web app (not ASP.NET Core) with just one Index.html page on IIS, we can access the app from another machine on the same network via, say, http://IP Address/MySimpleHtmlApp. So issue seems to be related to something on ASP.NET Core deployment on IIS. Question: What we may be missing and how to resolve it?

UPDATE: The IIS has default port 80 that is open. When we run the app directly from IIS on the server (i.e., http://localhost:80/MyWebapplication) it gives the following error:

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Detailed Error Information:
Module     IIS Web Core
Notification       BeginRequest
Handler    Not yet determined
Error Code     0x8007000d
Config Error       
Config File    \\?\D:\TestApp\PublishOutput\web.config

Requested URL      http://localhost:80/TestWebApp

Physical Path      D:\TestApp\PublishOutput
Logon Method       Not yet determined
Logon User     Not yet determined
Config Source:
   -1: 
    0:

Following is the web.config file (created by VS2017):

<?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=".\TestWebApp.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
  </system.webServer>
</configuration>
<!--ProjectGuid: 21c38c6d-7aff-4624-b310-a0f5f766b461-->
iis
asp.net-core
asked on Stack Overflow Oct 2, 2017 by nam • edited Oct 2, 2017 by nam

1 Answer

0

Well, first off, you're not really deploying this to IIS; you're self-hosting. If you want to run it under IIS, you need to create a site in IIS for it, drop in the published code, and configure the App Pool to run "No Managed Code". Then, you can pull up the site under whatever bindings you've added for it in IIS.

Second, your test case of a "simple website", it not utilizing a non-standard web port (it's using 80), while your ASP.NET Core app is (5000). This may very well be due to a firewall you have running, as most firewall appliances will block access by default to any non-standard port. You'll either need to open up a rule for that port on your firewall or host it on port 80, like you're doing with your "simple website".

answered on Stack Overflow Oct 2, 2017 by Chris Pratt

User contributions licensed under CC BY-SA 3.0