IHostingEnvironment.IsDevelopment()的等效功能应用程序

编程入门 行业动态 更新时间:2024-10-18 08:34:13
本文介绍了IHostingEnvironment.IsDevelopment()的等效功能应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在asp核心Startup.cs配置中,我们提供了一个IHostingEnvironment env参数,该参数公开了env.IsDevelopment()调用以确定您当前是否在Visual Studio f5调试会话或云部署方案中运行.在功能应用程序中有一个故事来确定同一件事,因此您可以编写仅在f5调试会话期间运行的代码,例如填充的(...,ClaimsPrincipal委托人)依赖项注入参数,其中,只有在将其部署到启用了云EasyAuth的环境中时,该参数才通常是分配的声明和角色.

In asp core Startup.cs Configure we are provided an IHostingEnvironment env parameter that exposes an env.IsDevelopment() call to determine if you are currently running in a visual studio f5 debug session or a cloud deployment scenario. In function app is there a story for determining this same thing so you can write code that only runs during f5 debug session, e.g. a populated (. . ., ClaimsPrincipal principal) dependency injected parameter where this is only normally assigned claims and roles when deployed into cloud EasyAuth enabled environment.

推荐答案

IHostingEnvironment.IsDevelopment()实际上检查ASPNETCORE_ENVIRONMENT环境变量是否设置为开发".如果这是您要执行的操作,则可以使用Environment.GetEnvironmentVariable()来检查该值.但是,要明确确定您是否处于F5调试会话中,应改为选择Debugger.IsAttached.

IHostingEnvironment.IsDevelopment() actually checks whether the ASPNETCORE_ENVIRONMENT environment variable is set to "Development". If that's what you want to do then you can use Environment.GetEnvironmentVariable() to check the value. However, to determine specifically if you're in an F5 debug session you should check Debugger.IsAttached instead.

更多推荐

IHostingEnvironment.IsDevelopment()的等效功能应用程序

本文发布于:2023-11-08 07:27:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1568728.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   功能   IHostingEnvironment   IsDevelopment

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!