Handling Secrets in Asp.Net (.Net Core) Web Application

In this Sample, we will see how we will handle the secrets in .Net Core web Application using Azure Key Vault.Installing the below NuGet Package DescriptionAs more and more applications moving into the cloud, the more and more securities that need to be handled carefully. Normall

C# (669.1 KB)
 
 
 
 
 
(0)
25 times
Add to favorites
10/14/2018
E-mail Twitter del.icio.us Digg Facebook
using Microsoft.Extensions.Configuration;
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using DemoSecrets.Models;

namespace DemoSecrets.Controllers
{
    public class HomeController : Controller
    {
        public IConfiguration Configuration { get; set; }

        public HomeController(IConfiguration config)
        {
            Configuration = config;
        }

        public IActionResult Index()
        {
            ViewData["myConnectionString"] = Configuration["myConnectionString"];
            return View();
        }

        public IActionResult About()
        {
            ViewData["Message"] = "Your application description page.";

            return View();
        }

        public IActionResult Contact()
        {
            ViewData["Message"] = "Your contact page.";

            return View();
        }

        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}