4

I am new to ASP.NET core and I am trying to just get the basic ASP.NET Core Web Application to deploy to a Windows 2012 R2 server.

I can build and run the project locally using Visual Studio express but when I deploy to the server I get a 502.5 error, the exact code is (0x80004005).

The log files are blank and the Event Viewer gives no more information than just the above error code.

I suspect there is something wrong with my Project.json file which looks like this:

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.1",
      "type": "platform"
    },
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Routing": "1.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

This is the default project.json file generated by Visual Studio.

GEOCHET
  • 20,623
  • 15
  • 71
  • 98
Michael Edwards
  • 5,680
  • 3
  • 37
  • 70
  • 2
    Possible duplicate of [ASP.NET Core 1.0 on IIS error 502.5](http://stackoverflow.com/questions/38624453/asp-net-core-1-0-on-iis-error-502-5) – hometoast Jan 25 '17 at 17:21
  • 1
    Did you read the manual and installed the "Windows Server Hosting" package? https://www.microsoft.com/net/download/core#/runtime/current Without it, it doesn't work. It contains AspNetCoreModule (It's based on `HttpPlatformHandler` and modified for ASP.NET core). Also you need the .NET Runtime, if you do not publish/deploy your app as self-contained – Tseng Jan 25 '17 at 17:44
  • If you are having this problem with a 32-bit asp.net core app try [this answer](https://stackoverflow.com/a/53562972/2292053) – Nathan Nov 30 '18 at 18:31

2 Answers2

2

Turns out that this was result of needing to install some windows updates and this problem:

api-ms-win-crt-runtime-l1-1-0.dll is missing when opening Microsoft Office file

Rather than install the version discussed in the above issue I whet into Programs and Features and ran a repair on Microsoft Visual C++ 2015 Redistributable.

The way I found this error was to convert the website to a standalone executable by performing the following steps:

In project.json remove "type":"platform" from the dependencies:

"dependencies": {
"Microsoft.NETCore.App": {
  "version": "1.0.1"     
},

Then define the Windows 12 R2 runtime:

"runtimes": {
   "win81-x64": {}
},

Then in the Website folder (the folder containing the project.json file) run the following commands from the command prompt:

dotnet build -r win81-x64
dotnet publish -c release -r win81-x64

The standalone app should be created in the folder \bin\Release\netcoreapp1.1\win81-x64.

Copy this to the server and then run it, a dialog should appear with a message similar to "api-ms-win-crt-runtime-l1-1-0.dll is missing".

From there google!

After doing all this I was able to run my Website from IIS.

Community
  • 1
  • 1
Michael Edwards
  • 5,680
  • 3
  • 37
  • 70
1

This issue is related to Windows updates - but if you are in a similar environment than I was (where you are unable to just install ALL updates), these are the 2 that fixed the issue for me:

I had the same error in question - and got nasty error message when typing 'dotnet' into CMD:

The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is missing

I solved this by manually installing the following 2 updates on Windows Server 2012 R2 (and the pre-requisites and all the other updates linked - read the installation instructions carefully on the Microsoft website):

  1. KB2919355
  2. KB2999226

Hope this helps someone.

Johan Foley
  • 198
  • 1
  • 9