ASP.NET Core hosting - 500 internal server error

user6542823 picture user6542823 · Jan 7, 2017 · Viewed 46.3k times · Source

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.

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();

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

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

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

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

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

I would really appreciate if someone could help me here.

Answer

Lukasz Makowej picture Lukasz Makowej · Jan 7, 2017

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

stdoutLogEnabled="true" stdoutLogFile=".\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 ;)


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

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

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


app.UseDeveloperExceptionPage();

app.UseDatabaseErrorPage();

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