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

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

问题描述

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

<块引用>

处理您的请求时出错.

开发模式

切换到开发环境将显示有关所发生错误的更多详细信息.
不应在已部署的应用程序中启用开发环境,因为这会导致向最终用户显示异常的敏感信息.对于本地调试,可以通过将ASPNETCORE_ENVIRONMENT 环境变量设置为Development 并重新启动应用程序来启用开发环境.

解决方案

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

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

<预><代码><配置><!--在 appsettings.json 中配置您的应用程序设置.在 http://go.microsoft.com/fwlink/?LinkId=786380 上了解更多信息--><system.webServer><处理程序><add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/></处理程序><aspNetCore processPath=".Application.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".logsstdout" forwardWindowsAuthToken="false"><环境变量><environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production"/></环境变量></aspNetCore></system.webServer></配置>

请参阅此帖子了解更多信息详情.

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:

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.

解决方案

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

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=".logsstdout" 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天全站免登陆