AspNetCoreModule icon indicating copy to clipboard operation
AspNetCoreModule copied to clipboard

.netcore 2.0 Preview 2 IIS Deployment Error 502.5

Open jkotalik opened this issue 7 years ago • 2 comments

From @Petermarcu on October 9, 2017 1:9 @nzcoward opened this here: https://github.com/dotnet/core/issues/788

I am unable to run a web application built in .netcore 2.0 preview 2 in IIS.

I did post a comment in #723 , however I have decided that the issue is different, as I am able to find the AspNetCoreModule after installing the Windows Hosting for .netcore 2.0 preview 2.

I am able to run the application just using Kestrel, so it appears to simply be the reverse proxy provided by the module.

I have done everything I can find with regards to trouble shooting as described for .netcore 1.x versions. This includes:

  • Adding IISConfiguration and Kestrel configuration in Program.cs (was missing in the new templates)
  • Ensuring the AspNetCoreModule is installed and in use by IIS
  • Tested both Standalone and Framework dependent deployments (including turning off the runtime framework in the application pool)
  • Using NetworkService as the Application Pool user
  • Running the deployed site using Kestrel (dotnet myapp.dll)
  • Review the web config and ensure it is set up correctly (<aspNetCore processPath="dotnet" arguments=".\MyApp.dll"...) and add logging (which logs nothing)
  • Set the ASPNETCORE_ENVIRONMENT environment variable in the web.config to 'Development'

I don't have the official links any longer, but the basic steps from Rick Strahl's blog have been followed.

Now, there is one VERY distinct difference between the errors that I have seen and mine with .netcore 2.0: the event viewer shows the error:

Application 'MACHINE/WEBROOT/APPHOST/MYAPP' with physical root 'C:\inetpub\wwwroot\myapp' failed to start process with commandline ' ', ErrorCode = '0x80070057 : 0.

The commandline argument is empty!

I did have .netcore 1.0, 1.1, previews, etc. installed on my machine previously, but they are all removed now.

The version of the AspNetCore.dll that I am running after installing the files from .netcore 2.0 WindowsHosting:

image

Based on the date, I assume it is the correct version, but this could be the problem! I have tried it with the previously installed version (i.e. before I installed the 2.0 one), but I didn't check the version on that installed assembly - it may be the same file... Hoping someone can tell me either way.

Because it runs in Kestrel without any problems, I do believe it is this module.

nzcoward commented on Aug 4 And after removing and then manually installing the 2.x SDKs, my projects no longer opened. Had to do a complete repair on VS 2017 to get the right things installed, and even then, not everything was installed properly.

Going back to PHP at this rate sounds like the best way to get my sanity back!

@DamianEdwards

nzcoward commented on Aug 5 Ok - so I am not aware of anything changing, but it seems to have resolved itself as of this morning.

I had given up, and went back to a WebApi2 project instead, which was easy to get up and running. I came to the conclusion that IIS itself was fine - so on a whim, I thought that I would try once more (I still had a single hair on my head, what could go wrong?)

Both Stand Alone and Framework Dependent deployments are working now.

There was ONE thing I never checked - which was that the AspNetCoreModule had installed itself into the site - it may not have been available there for whatever reason (I don't know this for certain - but I never checked). Perhaps the 4th restart of my computer managed to give that a kick.

One thing that I did change (but change back) was the site bindings. I had originally set it up with a hostname (referenced in my computer's hosts file to point to 127.0.0.1) and it sat alongside the Default Website that had *:80 binding. Now, I had thought about this earlier and disabled the Default Website, but the issue was still occurring. But the change I DID make was to set this site that wasn't working to have the *:80 binding when I deployed the WebApi2 app to it. I have since switched it back to just the api.mysite.com:80 binding and it is working.

Neither of the above 2 things seem likely resolutions - surely the module was there, and if not, yet another restart wouldn't do something a previous restart hadn't - and tweaking bindings, unless somehow they were cached, seems just as unlikely.

I do think that this issue is a good list of all the things to try, collated from a number of sites (official and unofficial) and blogs. It may help someone in the future if the list can be put somewhere.

But, things are working now, so the issue can be closed - I didn't want to do it myself, just in case it meant the issue was not longer easily searchable for the attempted resolutions. @nzcoward

nzcoward commented on Aug 5 • edited Actually, I think I may have discovered it... I thought I had made a change yesterday, where the 502.5 was still occurring, but perhaps not. I have just deployed another app this morning, and it had the 502.5 error, except that I was able to resolve it:

I had the application deployed to a folder, and had set up a virtual directory against the parent - path-wise it was a child folder also. Leaving it as a virtual directory, or letting IIS resolve the path resulted in the 502.5.

So I converted it to an application. And it works...

It is worth pointing out though, that the application is still using the parent application pool - it does not have its own.

This does actually feel like a bug with the AspNetCoreModule still - surely the application pool is defining the isolation level, and virtual directories should fall inside the scope of the app pool. Having said that, the root/parent is a blank site - there is no web.config at that level. Defining the directory as an application does indicate that there is an executable app - which may signal to the module, but does a top level site not defer to a child web.config in a virtual directory if there is one? Does this not happen in MVC5 or Owin regardless of a parent web.config existing? Curious... @sonphnt

sonphnt commented on Aug 25 Actually I have the same problem with error 502.5 in IIS when migrating from core 1.1 to core 2.0 final. Has anyone have the official document about how to deploy .net core 2.0 webapp to IIS?

Thanks

jkotalik avatar Oct 12 '17 06:10 jkotalik

@pan-wang @jhkimnew

jkotalik avatar Oct 12 '17 06:10 jkotalik

Confirming, I experienced the same exact problem and error codes, and the solution of converting to an application worked for me as well (thank you).

jacobmorehouse avatar May 01 '19 03:05 jacobmorehouse