如何将生产设置添加到我的luanchSettings.json文件中进行生产



我想设置我的dotnet核心mvc应用程序在ubuntu上运行。

如何为生产环境设置启动设置.json文件?

我目前有这个,但不知道如何更改生产的应用程序URL,并保留我的开发资源。非常困惑。。。

{
"iisSettings": {
"windowsAuthentication": false, 
"anonymousAuthentication": true, 
"iisExpress": {
"applicationUrl": "http://localhost:17009",
"sslPort": 44319
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"MyApp.Brain": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

launchSettings.json仅用于开发目的-告诉dotnet run或Visual Studio/IDE要设置什么。

例如,对于生产,您可以创建一个包含之类内容的appsettings.Production.json

{
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://*:1234"
}
}
}
}

或者使用其他方式配置端点,如ASPNETCORE_URLS环境变量或在启动应用程序时使用命令行参数(dotnet yourapp.dll --urls "http://*:1234"(。

有关Kestrel服务器的其他配置选项(linux上的默认设置(,请参阅Kestrel Options文档;有关linux上不同的托管选项,请参阅Host and Deploy ASP.NET Core文档。

最新更新