Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How to add an environment indicator into a razor page?

$
0
0

I wish to add something to a razor page so that when I inspect the page code behind, I'm able to tell if it is in Production, Staging, or Development mode. In this case, I'm adding a hidden field to tell me what mode the page is in. It is not the cleanest looking code. Any ideas on a different approach to insert a status water mark of sorts into the rendered code?

@if (Env.IsProduction()) {<input type="hidden" name="EnvironmentName" id="EnvironmentName" value="Production" />}@if (Env.IsStaging()){<input type="hidden" name="EnvironmentName" id="EnvironmentName" value="Staging" />}@if (Env.IsDevelopment()){<input type="hidden" name="EnvironmentName" id="EnvironmentName" value="Development" />}

The code behind currently looks like this:

enter image description here


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>