【问题标题】:Angular 7 and IIS 7: Error Swapping to the Development environmentAngular 7 和 IIS 7:切换到开发环境时出错
【发布时间】:2019-12-02 11:13:58
【问题描述】:

我的解决方案 NET Core 2.2 中有一个 Angular 7 文件夹。 当我使用 Visual Studio 2017 和 IIS Express 在调试模式下运行时,我可以查看网站并正确调用后端的代码 API。 因此,我在发布时选择了在 launchSettings.json 中设置的配置文件,并在我在页面中添加了 IIS 后将“bin\Release\netcoreapp2.2\publish”的内容复制到我的 Windows Server 的文件夹中,例如 http://localhost:8085/ ,以下错误:

Development Mode Swapping to the Development environment displays detailed information about the error that occurred.

The Development environment shouldn't be enabled for deployed applications. It can result in displaying sensitive information from exceptions to end users. For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development and restarting the app.

我在 web.config 中设置:

environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production"

这怎么可能? 提前致谢

【问题讨论】:

    标签: angular asp.net-core iis


    【解决方案1】:

    错误表示我们的应用程序存在问题,根本原因未显示在错误页面上。如果您在文件中记录您的 .NET 核心应用程序错误,请在该文件中查找详细的错误信息,这应该会告诉您我们的应用程序失败的确切原因。

    【讨论】:

    • 我管理类似于此页面“MVC 错误处理”wakeupandcode.com/handling-errors-in-asp-net-core 的错误,但在我用 web.config 编写的文件中,信息并不重要(handlerSetting name="debugFile"):
      [aspnetcorev2_inprocess.dll] 事件日志:'Application 'D:\myProject\Hello\' 成功启动了 coreclr in-process。'结束事件日志消息。
      [aspnetcorev2_inprocess.dll] 在应用程序 'D:\myProject\Hello\' 中启动 app_offline 监控
      [aspnetcorev2_inprocess.dll] 启动文件观察线程
    • 尝试添加事件记录器docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/…来捕获错误
    • 您也可以尝试通过运行生成的exe手动启动编译站点,这样您就可以在控制台中看到发生了什么。
    • 谢谢亚历山大!我用命令行 dotnet 解决,我在 dos 窗口中看到详细错误“SPA 默认页面中间件无法返回默认页面'/index.html',因为它没有找到”,然后我更改:spa.Options.SourcePath =“启动中的 ClientApp" 和文件 Angular.json 中的 "outputPath": "dist" :-) 再次感谢
    • 没问题,很高兴为您提供帮助,不要忘记将问题标记为已回答
    猜你喜欢
    • 2019-02-24
    • 2014-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-01
    • 1970-01-01
    • 2018-06-04
    • 2019-08-27
    相关资源
    最近更新 更多