Search code examples
asp.netasp.net-coreweb-hostinginternal-server-error

ASP.NET Core RESTfull API hosting - 500 internal server error


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.


Solution

  • 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.