ASP.NET Core部署到IIS错误:不应在已部署的应用程序中启用开发环境 [英] ASP.NET Core deployment to IIS error: Development environment should not be enabled in deployed applications

查看:7789
本文介绍了ASP.NET Core部署到IIS错误:不应在已部署的应用程序中启用开发环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我跟着这篇文章将我的ASP.NET MVC Core 1.0应用程序部署到使用IIS 10的Windows 10上的本地IIS。应用程序已成功部署并打开主页。我正在使用个人帐户身份验证。在主页上输入登录名/密码并单击登录按钮时,出现以下错误。我正在使用最新版本的ASP.NET Core和VS2015。我使用VS2015发布向导来发布应用程序。一切都在同一台机器上完成:

I followed this article to deploy my ASP.NET MVC Core 1.0 app to local IIS on my Windows 10 that is using IIS 10. The application deployed successfully and it opens the home page fine. I'm using Individual User Accounts Authentication. On the home page when I enter login/password and click Login button, I get the following error. I'm using the latest versions of ASP.NET Core and VS2015. I used VS2015 Publish wizard to publish the app. Everything is done on the same machine:


处理您的请求时出错。



开发模式



交换到开发环境将显示有关发生的错误的更多详细信息。

不应在已部署的应用程序中启用开发环境,因为它可能导致向最终用户显示异常的敏感信息。对于本地调试,可以通过将 ASPNETCORE_ENVIRONMENT 环境变量设置为开发并重新启动应用程序来启用开发环境。

An error occurred while processing your request.

Development Mode

Swapping to Development environment will display more detailed information about the error that occurred.
Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application.


推荐答案

首先,检查 ASPNETCORE_ENVIRONMENT 变量的值。您必须将此环境变量设置为生产(或除开发之外的其他环境)

First, check the value of ASPNETCORE_ENVIRONMENT variable. You will have to set this environment variable to "Production" (or other environment than Development)

否则,您可以更新 web.config 喜欢这样 -

Otherwise, you can update web.config like this-

<configuration>
  <!--
    Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
  -->
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath=".\Application.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false">
      <environmentVariables>
        <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" />
      </environmentVariables>
    </aspNetCore>
  </system.webServer>
</configuration>

请参阅发布以获取更多详细信息。

Refer this post for more details.

这篇关于ASP.NET Core部署到IIS错误:不应在已部署的应用程序中启用开发环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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