Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Relic Solution: Changes with .NET Core 2.2 and AspNetCoreModuleV2


#1

With .NET Core 2.2 comes a new IIS module, AspNetCoreModuleV2. This isn’t an update for the existing AspNetCoreModule but a new module itself. Old apps using the AspNetCoreModule will continue to work the same.

ASP.NET Core Module configuration reference | Microsoft Docs

The big change for us comes with In Process Hosting which allows you to run a .NET Core application directly within IIS:

This means that when a .NET Core application runs in IIS it will now run as part of the w3wp.exe app pool process rather than the app pool acting as a proxy to the dotnet.exe process. The .NET Core Agent will now be instrumenting w3wp.exe processes which you can see in profiler logs:

[Info ] 2018-12-13 21:01:47 Logger initialized.
[Info ] 2018-12-13 21:01:47 Found newrelic.config at: C:\ProgramData\New Relic\.NET Core\newrelic.config
[Info ] 2018-12-13 21:01:47 >-- New logging level set: Info 
[Info ] 2018-12-13 21:01:47 Command line: c:\windows\system32\inetsrv\w3wp.exe -ap "yachtcore" -a \\.\pipe\iisipmbf8d66b7-4156-4baf-a2ef-1cc81c9dc04e -h "C:\inetpub\temp\apppools\yachtcore\yachtcore.config" -w "" -m 0 -t 20 -ta 0
[Info ] 2018-12-13 21:01:48 New Relic .NET CoreCLR Agent v0.0.0.0
[Info ] 2018-12-13 21:01:48 Profiler initialized

This is controlled by the web.config. Compare this older web.config:

<configuration>
<system.webServer>
<handlers>
<add name=“aspNetCore” path="" verb="" modules=“AspNetCoreModule” resourceType=“Unspecified” />
</handlers>
<aspNetCore processPath=“dotnet.exe” arguments=".\yachtcore.dll" stdoutLogEnabled=“false” />
</system.webServer>
</configuration>

With a new Core 2.2 web.config:

<configuration>
<location path="." inheritInChildApplications=“false”>
<system.webServer>
<handlers>
<add name=“aspNetCore” path="" verb="" modules=“AspNetCoreModuleV2” resourceType=“Unspecified” />
</handlers>
<aspNetCore processPath=“dotnet” arguments=".\inhostcore.dll" stdoutLogEnabled=“false” stdoutLogFile=".\logs\stdout" hostingModel=“InProcess” />
</system.webServer>
</location>
</configuration>

The hostingModel=“InProcess” is the key part. This is the default and is what tells the AspNetCoreModuleV2 to run the ASP.NET Core app in the w3wp.exe process.

Environment variables can be set in the web.config just as before.

<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\inhostcore.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" >
	  				<environmentVariables>
			<environmentVariable name="CORECLR_ENABLE_PROFILING" value="1" />
			<environmentVariable name="CORECLR_PROFILER" value="{36032161-FFC0-4B61-B559-F6C5D41BAE5A}" />
			<environmentVariable name="CORECLR_NEWRELIC_HOME" value="C:\ProgramData\New Relic\.NET Core" />
			<environmentVariable name="CORECLR_PROFILER_PATH" value="C:\ProgramData\New Relic\.NET Core\NewRelic.Profiler.dll" />
			<environmentVariable name="NEW_RELIC_LICENSE_KEY" value="INSERT_YOUR_LICENSE_KEY" />
      </environmentVariables>
	  </aspNetCore>
    </system.webServer>
  </location>
</configuration>

One key difference is the “Enable 32bit Applications” app pool setting is inherited by the .NET Core application now. This means that if a .NET Core app pool has that setting enabled the CORECLR_PROFILER_PATH must point to a 32bit version of the agent.

If an app pool has “Enable 32bit Applications = true” and the CORECLR_PROFILER_PATH points to a 64bit agent, nothing will be logged and the NewRelic.Profiler.dll won’t be loaded into the w3wp.exe process despite the correct environment variables being present.

In ProcMon you would see this as the process having a few interactions with the 64bit NewRelic.Profiler.dll but no other agent files or attempts to access the log directory:

Note that this could be different from app to app on the same server.