namespace FetchAppsettingsValue.Controllers
{
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using System.Collections.Generic;
[Route("api/Configuration")]
[ApiController]
public class ConfigurationController : ControllerBase
{
private readonly IConfiguration _config;
public ConfigurationController(IConfiguration config)
{
_config = config;
}
// GET: api/Configuration
[HttpGet]
public IEnumerable<string> Get()
{
var result = _config.GetValue<string>("Logging:LogLevel:Default"); // "Information"
return new string[] { result.ToString() };
}
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter