如何知道产品的环境名称? [英] How to know environment name of a product?

查看:70
本文介绍了如何知道产品的环境名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网络表单应用程序。我想知道它在哪个环境中运行(例如生产或预览或开发或测试)。这怎么可能?我可以在web.config中存储一些密钥来实现吗?



我尝试过:



尝试搜索答案但找不到。

I have a web forms application. I want to know which environment it is running in(e.g production or preview or development or testing). How is it possible? Can I store some key in web.config to achieve it?

What I have tried:

Tried searching for the answer but could not find.

推荐答案

如果您的应用程序正在运行,以下代码行将为您提供真值本地。

The following line of code will give you a true value if your application is running locally.
bool isLocal = HttpContext.Current.Request.IsLocal;



对于生产/登台/ QA,您可能需要在web.config文件中包含一个密钥。我还建议您查看 Transfor文件 [ ^ ]。这是理解各种部署服务器上不同配置的一个很好的起点(QA / Staging / Production)



希望它有所帮助。


For production/staging/QA you may need to include a key in your web.config file. I would also suggest you to look into Transfor File[^]. This is a good starting point to understand different configuration on various deployment servers(QA/Staging/Production)

Hope it helps.


这篇关于如何知道产品的环境名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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