Reputation: 135
I am trying to figure out this bug for a week but I still cant find the error.
System I am currently running is Linux Ubuntu 16.04
I have set everything to production in launchSettings.json
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:51754/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production"
}
},
"FilmerCore": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production"
},
"applicationUrl": "http://localhost:51755"
}
}
}
And this is my web.config
<?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=".\FilmerCore.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</configuration>
<!--ProjectGuid: 5be3ea4c-66c2-42b0-8583-29c6bf415674-->
Aslo I am using nginx as a reverse proxy. The main config is this
[Unit]
Description=Filmer - .NET movie platform
[Service]
WorkingDirectory=/var/aspnetcore/filmer
ExecStart=/usr/bin/dotnet /var/aspnetcore/filmer/FilmerCore.dll
Restart=always
RestartSec=10 # Restart service after 10 seconds if dotnet service crashes
SyslogIdentifier=filmer
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Development
[Install]
WantedBy=multi-user.target
Upvotes: 0
Views: 1713
Reputation: 64288
Of course it won't work, because you didn't set the environment variable.
web.config
is only there for IIS. nginx can't do anything with it. launchSettings.json
is only used for Visual Studio to launch your project when you hit F5. You must look into ngnix documentation on how to set environment variables or set a global variable in the shell (which will be valid for all applications on the server) like export ASPNETCORE_ENVIRONMENT=Development
.
Upvotes: 2