IHostingEnvironment.IsDevelopment()的等效功能应用程序 [英] function app equivalent for IHostingEnvironment.IsDevelopment()

查看:579
本文介绍了IHostingEnvironment.IsDevelopment()的等效功能应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In asp.net 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()的等效功能应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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