ASP.NET Core 1.0 on IIS error 502.5
I was able to fix it by running
"C:\Program Files\dotnet\dotnet.exe" "C:\fullpath\PROJECT.dll"
on the command prompt, which gave me a much more meaningful error:
"The specified framework 'Microsoft.NETCore.App', version '1.0.1' was not found. - Check application dependencies and target a framework version installed at: C:\Program Files\dotnet\shared\Microsoft.NETCore.App - The following versions are installed: 1.0.0 - Alternatively, install the framework version '1.0.1'.
As you can see, I had the wrong NET Core version installed on my server. I was able to run my application after uninstalling the previous version 1.0.0 and installing the correct version 1.0.1.
I got this working with a hard reset of IIS (I had only just installed the hosting package).
Turns out that just pressing 'Restart' in IIS Manager isn't enough. I just had to open a command prompt and type 'iisreset'
So I got a new server, this time it's Windows 2008R2 and my app works fine.
I can't say for sure what the problem was with the old server but I have one idea.
So because I previously compiled the app without any platform in mind it gave me the dll
version which only works if the target host has .Net Core Windows Hosting
package installed. In my case it was installed and that was fine.
After the app didn't work I decieded to compile it as a console app with win7-x64
as runtime. This time the moment I ran the exe
of my app on the server, it crashed with an error about a missing dll:
The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is missing
That dll is from Universal C Runtime that's included in the Visual C++ Redistributable for Visual Studio 2015.
I tried to install that package (both x64 & x86) but it failed each time (don't know why) on Windows Server 2012 R2.
But when I tried to install them in the new server, Windows Server 2008 R2, they successfully installed. That might have been the reason behind it, but still can't say for sure.
I had the same problem, in my case it was insufficient permission of the user identity of my Application Pool, on Publishing to IIS page of asp.net doc, there is a couple of reason listed for this error:
- If you published a self-contained application, confirm that you didn’t set a platform in
buildOptions
ofproject.json
that conflicts with the publishing RID. For example, do not specify a platform of x86 and publish with an RID of win81-x64 (dotnet publish -c Release -r win81-x64
). The project will publish without warning or error but fail with the above logged exceptions on the server. - Check the
processPath
attribute on the<aspNetCore>
element in web.config to confirm that it isdotnet
for a portable application or .\my_application.exe for a self-contained application. - For a portable application,
dotnet.exe
might not be accessible via the PATH settings. Confirm thatC:\Program Files\dotnet\
exists in the System PATH settings. - For a portable application,
dotnet.exe
might not be accessible for the user identity of the Application Pool. Confirm that the AppPool user identity has access to theC:\Program Files\dotnet
directory. - Confirm that you have correctly referenced the IIS Integration middleware by calling the
.UseIISIntegration()
method of the application’sWebHostBuilder()
. - If you are using the
.UseUrls()
extension method when self-hosting with Kestrel, confirm that it is positioned before the.UseIISIntegration()
extension method onWebHostBuilder()
..UseIISIntegration()
must set theUrl
for the reverse-proxy when running Kestrel behind IIS and not have its value overridden by.UseUrls()
.
In my case it was the fourth reason, I changed it by right clicking my app pool, and in advanced setting under Process Model, I set the Identity to a user with enough permission: