ASP.NET 核心 RESTfull API 托管 - 500 内部服务器错误
ASP.NET Core RESTfull API hosting - 500 internal server error
我正在尝试发布和托管我的 .NET Core 应用程序。当我尝试使用来自 API (example.com/pets/users
) 的 GET 请求检索数据时,出现 500 Internal Server Error。 example.com/pets
是我的 API 发布的 URL。
我的网络配置如下所示:
<?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>
我觉得还不错。
stdout 日志是这样说的:
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.
到底有什么问题?我检查了我的远程数据库连接,它是正确的。
如果有人能在这里帮助我,我将不胜感激。
我解决了这个问题。问题是我在服务器上新创建的虚拟目录上发布了 API。当我在子域上发布 API 时一切正常。
上述警告错误的解决方法:编辑您的 IIS 应用程序池以启用用户配置文件加载。应用程序池 > 高级设置 > 加载用户配置文件:True
example.com/pets/users
) 的 GET 请求检索数据时,出现 500 Internal Server Error。 example.com/pets
是我的 API 发布的 URL。
我的网络配置如下所示:
<?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>
我觉得还不错。
stdout 日志是这样说的:
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.
到底有什么问题?我检查了我的远程数据库连接,它是正确的。
如果有人能在这里帮助我,我将不胜感激。
我解决了这个问题。问题是我在服务器上新创建的虚拟目录上发布了 API。当我在子域上发布 API 时一切正常。
上述警告错误的解决方法:编辑您的 IIS 应用程序池以启用用户配置文件加载。应用程序池 > 高级设置 > 加载用户配置文件:True