An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# EnvInfo

[![License](https://img.shields.io/github/license/ppech/dotnet-hostsctl)](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
[![Latest version](https://img.shields.io/nuget/v/EnvInfo.MVC.svg)](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 `