0
votes

Problems deploying .NET Core to IIS. I followed the steps as below:

  1. Created a website using .NET Core 3.1 with Visual Studio
  2. Created website inside IIS (pointing to an empty physical path C:\inetpub\mywebsite and address mywebsite.core.com)
  3. Published my website from Visual Studio into the same folder, C:\inetpub\mywebsite
  4. Host entry to browse from browser e.g. went to drivers\etc\hosts and added line 127.0.0.1 mywebsite.core.com
  5. Installed bundles from here:https://dotnet.microsoft.com/download/dotnet-core/thank-you/runtime-aspnetcore-3.1.5-windows-hosting-bundle-installer

Error is:

HTTP Error 500.30 - ANCM In-Process Start Failure Common solutions to this issue: The application failed to start The application started but then stopped The application started but threw an exception during startup Troubleshooting steps: Check the system event log for error messages Enable logging the application process' stdout messages Attach a debugger to the application process and inspect For more information visit: https://go.microsoft.com/fwlink/?LinkID=2028265

I have a feeling this might be related to my launchSettings.json file, not sure how it should be adapted...

When I launched my site from Visual Studio it used to open directly to a swagger link, but now after publishing to IIS I can no longer launch it from Visual Studio (unable to connect to webserver IISExpress)... Any help please?

It's a .NET Core 3.1 console app with a Startup that opened a swagger with my APIs before I attempted to publish to IIS.

Later edit: https://docs.microsoft.com/en-us/aspnet/core/test/troubleshoot-azure-iis?view=aspnetcore-3.1 this suggests two possible causes: lack of permission to key vaults (not a preoblem, I am logged in Azure with azure cli); and the other one is: "The app is misconfigured due to targeting a version of the ASP.NET Core shared framework that isn't present. Check which versions of the ASP.NET Core shared framework are installed on the target machine."

Later edit: The web.config from C:\inetpub\mywebsite looks like this:

 <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <location path="." inheritInChildApplications="false">
        <system.webServer>
          <handlers>
            <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
          </handlers>
          <aspNetCore processPath="dotnet" arguments=".\XXX.MyWebsite.Api.RestApi.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="outofprocess" />
        </system.webServer>
      </location>
    </configuration>

I actually changed hostingModel="inprocess" to: hostingModel="outofprocess"

And my Project > Properties > Debug looks like this:

enter image description here

(as you can see I changed from In Process to Out of Process)

and the bindings in IIS look like this: enter image description here

UPDATE: After all of this, my error changed to:

HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure Common solutions to this issue: The application process failed to start The application process started but then stopped The application process started but failed to listen on the configured port

(it was initially 500.30)

Not really sure what else to try. How do I check if the port is well configured?

2
Re keyvault permissions: you have access, but what user is the app pool running as in IIS?pinkfloydx33
You can check the error log on by setting true the stdoutLogEnabled on the web.config and let us know what error do you get. You will see the log file on the log folder on your publish folder. It is possible that it is a certificate issue.Ralph Olazo
If the server has .NET Core 2.2 installed check to make sure it has the latest update to 2.2. There is a bug in 2.2.1 (I think, don't quote me) that causes this error. You'd think having 3 or 3.1 installed would mitigate that but it doesn't. If that is your problem, you can also publish as self-contained to get it working.Crowcoder
Run some basic diagnostics to rule out common mistakes first, docs.jexusmanager.com/tutorials/ancm-diagnostics.html Edit your question to include the report if the problem remains.Lex Li

2 Answers

0
votes

Try to follow this article.
https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/development-time-iis-support?view=aspnetcore-3.1

If it does not work - make sure that your application pool is enabled in IIS for you web application. Try also to restart IIS.

0
votes

Debugging Via Kestrel Way

Kindly try to publish your application to a particular folder . Dotnet Core Cli Command for publishing. Below command publishes to "output" folder

 dotnet publish -o output

After moving to publish folder via cd command . Type dotnet <project-name>.dll . Use your project name instead of <project-name>

your application should be running and it should be working perfectly . if you face any issue , it is due to application error

Deploy to IIS

After that for hosting your application to production or staging , Install IIS (not express) and .NET core hosting bundle.[click here to download hosting bundle]

After that , you can follow this guide