简体   繁体   English

如何在“生产”环境中Web部署ASP.NET Core应用程序?

[英]How to WebDeploy an ASP.NET Core application in “Production” environment?

I created a test ASP.NET Core web app and published it to azure via Web Deploy... 我创建了一个测试ASP.NET Core Web应用程序,并通过Web Deploy将其发布为Azure。

When I try to access a page controller via the site URL, I have the following: 当我尝试通过站点URL访问页面控制器时,出现以下情况: 在此处输入图片说明

I have mainly non-modified by default 我主要是默认情况下未修改 在此处输入图片说明 also a lauchSettings.json file with 还有一个lauchSettings.json文件,

{
    "iisSettings": {
        "windowsAuthentication": false,
        "anonymousAuthentication": true,
        "iisExpress": {
            "applicationUrl": "http://localhost:23403/",
            "sslPort": 0
        }
    },
    "profiles": {
        "IIS Express": {
            "commandName": "IISExpress",
            "launchBrowser": true,
            "environmentVariables": {
                "ASPNETCORE_ENVIRONMENT": "Development"
            }
        },
        "IIS Express (Staging)": {
            "commandName": "IISExpress",
            "launchBrowser": true,
            "environmentVariables": {
                "ASPNETCORE_ENVIRONMENT": "Staging"
            }
        },
        "IIS Express (Production)": {
            "commandName": "IISExpress",
            "launchBrowser": true,
            "environmentVariables": {
                "ASPNETCORE_ENVIRONMENT": "Production"
            }
        },
        "MyApplication": {
            "commandName": "Project",
            "launchBrowser": true,
            "environmentVariables": {
                "ASPNETCORE_ENVIRONMENT": "Development"
            },
            "applicationUrl": "http://localhost:23404"
        }
    }
}

What should I do in order to modify the ASPNETCORE_ENVIRONMENT variable when publishing it via 通过发布时如何修改ASPNETCORE_ENVIRONMENT变量 在此处输入图片说明

PS. PS。

I updated the App Settings in Azure portal, like this 我像这样更新了Azure门户中的应用程序设置 在此处输入图片说明 then republished the application... 然后重新发布该应用程序...

But nothing changed, I have the same Error ... 但是什么都没有改变,我有同样的错误 ...

launchsettings.json only affects local development I think. launchsettings.json仅影响本地开发。 It won't affect it in Azure. 在Azure中不会影响它。 I think you should be able to define an app setting with key ASPNETCORE_ENVIRONMENT set to eg Development. 我认为您应该能够将ASPNETCORE_ENVIRONMENT键设置为“开发”来定义应用程序设置。

I thinks you are mixing 2 questions here. 我认为您在这里混了2个问题。

  1. Deployment to production 部署到生产
  2. Monitoring bugs 监控错误

As about deployment, it looks like you did everything correctly - your site is hosted using not Development environment. 关于部署,您似乎正确完成了所有操作-您的网站不是使用开发环境托管的。 This is exactly what error page tells you. 这正是错误页面告诉您的内容。

As about bugs, you definitely would not like anyone to see your connection strings or anything else an error message may contain. 关于错误,您绝对不希望任何人看到您的连接字符串或错误消息可能包含的其他任何内容。 So you need to add some logging to see what really fails. 因此,您需要添加一些日志记录以查看真正失败的原因。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在生产中实例化ASP.NET Core应用程序 - Instantiation of ASP.NET Core application in production 在 ASP.NET Core Web API 设置生产环境的launchurl - Set launchurl for production environment in ASP.NET Core Web API 如何在环境变量中正确存储连接字符串,以便通过生产ASP.Net Core MVC应用程序进行检索 - How to correctly store connection strings in environment variables for retrieval by production ASP.Net Core MVC applications 如何在生产环境中禁用 Asp.Net Core web API 中的 400 Bad request 的消息正文? - how to disable 400 Bad request's message body in Asp.Net Core web API in production environment? 如何在生产和开发环境中始终如一地获取ASP.NET 5 DNX项目的应用程序基础路径? - How to consistently get application base path for ASP.NET 5 DNX project on both production and development environment? 如何配置ASP.NET应用程序的环境? - How to configure the environment of an ASP.NET application? ASP.Net Core 应用程序和 Environment.GetEnvironmentVariables() 奇怪的行为 - ASP.Net Core application and Environment.GetEnvironmentVariables() strange behavior 如何设置要考虑发布 ASP.NET Core 应用程序的 AS.NETCORE_ENVIRONMENT - How to set ASPNETCORE_ENVIRONMENT to be considered for publishing an ASP.NET Core application 如何将 ASP.NET Core UserSecrets 部署到生产环境 - How to deploy ASP.NET Core UserSecrets to production 如何在 ASP.NET Core 3.1 生产中配置 IdentityServer - How to configure IdentityServer in ASP.NET Core 3.1 production
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM