0
votes

According to this topic I'm trying to publish and host my .NET Core application. I am getting 500 Internal Server Error when I try to retrieve data using GET request from my API (example.com/pets/users). example.com/pets is an URL where my API is published.

My webconfig looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet" arguments=".\Pets.Api.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
  </system.webServer>
</configuration>

which I believe is pretty ok.

stdout log says this:

warn: Microsoft.Extensions.DependencyInjection.DataProtectionServices[59]

Neither user profile nor HKLM registry available. Using an ephemeral key repository. Protected data will be unavailable when application exits.

warn: Microsoft.AspNetCore.DataProtection.Repositories.EphemeralXmlRepository[50]

Using an in-memory repository. Keys will not be persisted to storage.

Hosting environment: Production

Content root path: D:\HostingSpaces\xardaslord\example.com\wwwroot\pets

Now listening on: http://localhost:13556

Application started. Press Ctrl+C to shut down.

What exactly can be wrong? I cheked my remotely DB connection and it is correct.

I would really appreciate if someone could help me here.

2
There isn't a lot to go on here. In my experience, when you go from running locally to in development mode to hosted in production mode, there can be issues with configuration items being missing. Do you use user secrets locally? If you do, you will not have them in production. This is just an example...GlennSills
I changed App Pool to No Managed Code, and now when I try to do GET request example.com/pets/users I get 403 - Forbidden: Access is denied.XardasLord
What is the application identity associated with the app pool and does it have permission to read the deployment folder?GlennSills

2 Answers

2
votes

A workaround for the above warn errors: edit your IIS App Pool to enable User Profile Loading. App pool > Advanced Settings > Load User Profile: True

0
votes

I fixed the problem. The problem was that I published that API on the new created virtual directory on the server. When I published API on the subdomain everything works fine.