https://github.com/ppech/env-info
Enviroment info controls for Mvc/RazorPages and DotVVM
https://github.com/ppech/env-info
Last synced: 5 months ago
JSON representation
Enviroment info controls for Mvc/RazorPages and DotVVM
- Host: GitHub
- URL: https://github.com/ppech/env-info
- Owner: ppech
- License: mit
- Created: 2022-12-09T16:48:00.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-02-17T07:39:41.000Z (over 1 year ago)
- Last Synced: 2025-06-12T05:05:32.217Z (about 1 year ago)
- Language: C#
- Homepage:
- Size: 186 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EnvInfo
[](LICENSE)
EnvInfo is a collection of Mvc/RazorPages tag helpers and DotVVM controls that provides environment information
for your application. It is useful for identifing between different environments like Development, Staging, and Production.
## Features
* display environment name (e.g., DEV, STAG, PROD) based on the current environment
* ability to change environment name or visility using configuration
* display Bootstrap breakpoint name (e.g., xs, sm, md, lg, xl) based on the current screen width
* ability to change predefined styles using custom css
## Usage
Install nuget package for each UI framework you use in your project. Then register required service in `Program.cs` or `Startup.cs` file
```csharp
builder.Services.AddEnvInfo();
```
By default, the Name is derived from the environment name and Visible is set to true
for the development environment. Then tries to load the configuration section `EnvInfo`
and set the values.
```json
"EnvInfo": {
"Name": "ALPHA",
"Visible": true
}
```
You can provide custom configuration section.
```csharp
services.AddEnvInfo(Configuration.GetSection("App.EnvInfo"));
```
Or you can override Name directly in code
```csharp
builder.Services.AddEnvInfo("APLHA");
```
Or simply provide custom configuration object
```csharp
services.AddEnvInfo(new EnvInfoOptions
{
Name = "CUSTOM",
Visible = true
});
```
### MVC / Razor Pages
[](https://www.nuget.org/packages/EnvInfo.MVC)
Add tag helpers import to `_ViewImports.cshtml` file
```razor
@addTagHelper *, EnvInfo.Mvc
```
Below is basic usage snippet that displays environment name. Place it before `