ASP.NET Core托管-500个内部服务器错误 [英] ASP.NET Core hosting - 500 internal server error

查看:645
本文介绍了ASP.NET Core托管-500个内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用支持ASP.NET Core的托管提供程序作为ASP.NET Core项目发布.我收到500 Internal Server Error,我认为这很常见.因此,我在互联网和各种论坛中进行了搜索,然后在web.config中检查了processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%",它们看起来可以用processPath="dotnet" and arguments=".\MyApplication.dll"正确转换.

I am trying to publish as ASP.NET Core project with a hosting provider that supports ASP.NET Core. I am getting 500 Internal Server Error which I believe is very common. So I searched through the internet and various forums and then I checked the processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" in web.config and they look to be correctly converted with processPath="dotnet" and arguments=".\MyApplication.dll".

我还检查了连接字符串,它指向正在工作的生产数据库服务器.我通过将连接字符串更改为生产数据库并在本地运行项目来确认数据库连接.它可以正常工作,并且可以访问生产数据库.

I also checked the connection string and it points to production DB server that's working. I confirmed the DB connection by changing the connection string to production DB and running project local. It works and I get the production DB access.

我还尝试通过在Startup.cs中使用以下内容获取错误信息(与env无关):

I also tried to get the error info by using the below in my Startup.cs (irrespective of env):

app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
app.UseBrowserLink();

我还在web.config中启用了stdoutLog,但是我也没有看到该文件夹​​:

I have also enabled stdoutLog in web.config, but I don't see that folder either:

stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout"

我还尝试将launchSettings.json中的applicationUrl和launchUrl更改为我的prod Url,但效果不佳.

I also tried to change applicationUrl and launchUrl in launchSettings.json to my prod Url, but that didn't work as well.

因此,"500 Internal Server Error"拒绝消失,并且我仍然没有有用的错误消息.该页面仅显示:

So, the 500 Internal Server Error refuses to go away, and I still don't have a useful error message. The page just says:

糟糕. 500内部服务器错误 启动应用程序时发生错误.

Oops. 500 Internal Server Error An error occurred while starting the application.

如果有人可以在这里帮助我,我将不胜感激.

I would really appreciate if someone could help me here.

推荐答案

我还在web.config中启用了stdoutLog,但是我也没有看到该文件夹​​:

I have also enabled stdoutLog in web.config as but I don't see that folder either:

stdoutLogEnabled ="true"; stdoutLogFile =.\ logs \ stdout"

stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout"

这里有一个窍门-您必须手动创建文件夹logsstdout-然后只有IIS才会在logs文件夹内创建日志文件(并非您所期望的stdout)-不要不要问我为什么,因为我不知道为什么;)

There is one trick here - you must create both folders logs and stdout manually - then and only then IIS will create log file inside logs folder (not stdout as you could expect) - don't ask me why, because I don't know why ;)

糟糕. 500 Internal Server Error启动应用程序时发生错误.

Oops. 500 Internal Server Error An error occurred while starting the application.

通常,这表示Startup.cs中的配置存在问题-最常见的问题包括DB本身问题,迁移问题(如果使用Code First方法),appsettings.js问题,社交登录问题凭据(例如缺少SecretKey)...

Usually, means problems with a configuration in Startup.cs - the most common problems include an issue with DB itself, an issue with migrations (if you are using Code First approach), problems with appsettings.js, problems with Social Logins credentials (like missing SecretKey)...

请参考.\logs\stdout中的日志文件-这是查找有关该问题的详细信息的最快方法:)

Please refer to log file in .\logs\stdout - this is the quickest way to find details about the problem :)

app.UseDeveloperExceptionPage();

app.UseDeveloperExceptionPage();

app.UseDatabaseErrorPage();

app.UseDatabaseErrorPage();

这些将在WebApp完全启动后起作用,但在启动应用程序时不会起作用.

Those will work after your WebApp fully started, but not while starting the application.

这篇关于ASP.NET Core托管-500个内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆