dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.35k stars 9.99k forks source link

aspnetcorev2_inprocess.dll #23713

Closed twisterbr closed 4 years ago

twisterbr commented 4 years ago

My setup: Windows 2008 R2 IIS 7.5 .NET Core 3.1.5 hosting bundle

I deployed an application with default parameters via dotnet CLI (dotnet publish -o L:\dotnet\appfolder) and published it on my IIS server, with following web.config parameters:

<system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*"
        modules="AspNetCoreModuleV2" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet"
                arguments=".\myApp.dll" 
                stdoutLogEnabled="false" 
                stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" 
                hostingModel="InProcess" />
  </system.webServer>

When I try to run my application via web/iis, I get: 500.33 - ANCM Request Handler Load Failure And on windows event viewer I get: Could not find the assembly 'aspnetcorev2_inprocess.dll' referenced for the in-process application. Please confirm the Microsoft.AspNetCore.Server.IIS or Microsoft.AspNetCore.App is referenced in your application.

On C:\Program Files\IIS\Asp.Net Core Module\V2\13.1.20142 I only have aspnetcorev2_outofprocess.dll and not aspnetcorev2_inprocess.dll Would be that be the issue?

How can I manage to install aspnetcorev2_inprocess module to work on IIS?

guardrex commented 4 years ago

@twisterbr ... I don't think the V2 module is supported on that OS. I think you'll need Windows Server 2012 R2 or later.

https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-3.1#supported-operating-systems.

twisterbr commented 4 years ago

@guardrex https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-3.1 In here it says its supported on 2008 R2 for azure app service. I don't understand why they make it available for azure cloud with windows but not for windows outside their cloud environment.

guardrex commented 4 years ago

I think that's a missed update ...

https://github.com/dotnet/AspNetCore.Docs/pull/16506#pullrequestreview-346809599

When engineering confirms here, I'll update that document.

twisterbr commented 4 years ago

@guardrex ok, thank you for the information.

I installed dotnetcore 2.1 (supports on 2008 R2, right?), rebooted the server, I see the module loaded on IIS (AspNetCoreModule) and now is giving me HTTP Error 502.5 - Process Failure and Application 'MACHINE/WEBROOT/APPHOST/DIR' with physical root 'D:\Inetpub\LocalUser\DIR\httpdocs\' failed to start process with commandline 'dotnet .\myApp2.dll', ErrorCode = '0x80004005 : 0.

I tried changing processPathto full dotnet.exe path but it still doesnt work. I can run the application from the commandline without any issue (on the server), so I guess the problem here could be something related to permissions on Application Pool or something on IIS.

The Application pool is set to: .NET Framework version = No managed code Enable 32bit application = False (default) Managed pipeline mode = integrated (default) Identity = ApplicationPoolIdentity

my 'new' web.config: `

<aspNetCore processPath="dotnet"
            arguments=".\myApp2.dll" 
            stdoutLogEnabled="false" 
            stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" 
            hostingModel="InProcess" />

</system.webServer>`

This is a simple app, the one created by dotnet new console -o myApp2 where it only prints 'hello world'.

guardrex commented 4 years ago

In-proc hosting didn't land until 2.2, so you can remove the hostingModel setting.

The only entry that we have for that error code (and it's an awfully old entry) is ...

https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/azure-iis-errors-reference?view=aspnetcore-3.1#platform-conflicts-with-rid

Make sure you disable the app pool, completely blow away the entire deployment folder+re-deploy, and re-enable the app pool. Lingering gremlins might kill an app when it's being totally replaced (but it is a good sign that you were able to run it from the command line).

Try turning on the stdout logging (briefly, don't use it for general logging) and see what it says (stdoutLogEnabled="true"). Just to be on the safe side, add a logs folder to the deployment root. The last few years of ASP.NET Core Modules can create the folder for you, but idk if the V1 module was updated to do that for you.

twisterbr commented 4 years ago

I did exactly as you suggested but i'm still getting IIS 502.5 Error (ErrorCode = '0x80004005) Funny thing is that stdout log file is writing the 'Hello world!' that it should be writing to the browser.

Console.writeline() writes to the browser, right?

guardrex commented 4 years ago

It writes to the console.

jkotalik commented 4 years ago

This is a simple app, the one created by dotnet new console -o myApp2 where it only prints 'hello world'.

An app hosted on IIS needs to be a web app, not a console app. I think that's why both of the issues you hit occurred; the native dll for IIS inproc wasn't present, therefore causing the app to fail to start. Same with out of proc.

Can you try running an app with dotnet new web -o MyApp2 instead and see if that works?

ghost commented 4 years ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

See our Issue Management Policies for more information.