Davood
Davood

Reputation: 5635

How to config IIS to run .net core 2.2?

1- On visual studio 2019 and .net core 2.2, created a default web application and didn't change any thing on my project, just publish it.

2- Installed the same version of the run-time from this link and put publish folder on the IIS (Windows 10 X64 enterprise), port 5000.

3- On the IIS changed CLR version to "No Managed Code" and brows website but I got this error message:

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       Unknown
Handler    Not yet determined
Error Code     0x8007000d
Config Error       
Config File    \\?  \C:\WebApplication1\WebApplication1\bin\Release\netcoreapp2.2\publish\web.config
Requested URL      http://localhost:5000/
Physical Path      
Logon Method       Not yet determined
Logon User     Not yet determined

After looking for this error code "Error Code 0x8007000d" on this link I do not know what's the problem. Should I set a config or what?

Edited: This application works fine on visual studio

Upvotes: 1

Views: 3762

Answers (2)

Annunaki_Selva
Annunaki_Selva

Reputation: 81

To Host .net core app to IIS, Below are the checklist which I managed to resolve

  • install .net core bundle (below 2.2 v1) and (3.0 and above v2)
    • Sometime when x86 and x64 .net core version may make problem
      that time in visual studio you can't choose .net core version even after installing particular version
      • To resolve this i usually uninstall all versions and work with x64 version of .net core runtime
  • Restart the iis "net stop was /y" then "net start w3svc"
  • After installing go and check in IIS Modules you can able to see v1 and v2
  • Create an application pool with no managed clr version (.net core app). For framework app use (v4.0)
  • In program.cs use "UseIISIntegration()"

error

Application 'C:\TestCoreApp\' failed to start. Exception message:
Could not find dotnet.exe at 'C:\TestCoreApp\dotnet.exe' or
using the system PATH environment variable. Check that 
a valid path to dotnet is on the PATH and 
the bitness of dotnet matches the bitness of the IIS worker process.

in web config change processPath="C:\Program Files\dotnet\dotnet.exe" from processPath="dotnet.exe" or add path to environment variable

cross check below in config.xml

<?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="C:\Program Files\dotnet\dotnet.exe" arguments=".\Webpi.test.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess">
        <environmentVariables>
          <environmentVariable name="COMPLUS_ForceENC" value="1" />
          <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
        </environmentVariables>
      </aspNetCore>
    </system.webServer>
  </location>
</configuration>

error :

Unable to load 'C:\Program Files\dotnet\host\fxr\3.1.0\hostfxr.dll'. This might be caused by a bitness mismatch between IIS application pool and published application.

solution

check whether your application pool has "No Managed code" in .net clr version enter code here`

Upvotes: 3

Install .NET Core 2.2 Runtime & Hosting Bundle for Windows and simply refresh your page. The error is caused because AspNetCoreModule is not installed in your PC.

You can read more about ASP.NET Core Module here.

Upvotes: 3

Related Questions