skip to Main Content

Welcome

Say hello to the toggle bar. This is an optional section you can use to display any content you'd like. Simply select a page from the theme panel and the content of the page will display here. You can even use the drag and drop builder to create this! This is a perfect place for your company mission statement, alerts, notices or anything else.

Get In Touch

Email: support@total.com
Phone: 1-800-Total-Theme
Address: Las Vegas, Nevada

Our Location

togglebar-map

[Security] – User Secrets

Post Series: ASP.NET Core Security

Purpose

You don’t want your passwords and other secrets stored in your source code. Store secrets outside the repository during development

Setting Up

1) Install the following NuGet package:

 

2) Add following code

3) Create secret class

4) Add to Startup.cs

 

Adding user secrets

secrets.json store in

not in respository => should on used for development purposes

Edit => right click Manage User Secrets

Retrieving user secrets

 

Command prompt

Now you can open a command prompt window and navigate to your project folder. There are a couple of commands and I’m going to show some of them.

  • dotnet user-secrets –help
    Executing this command will show you information about the user secrets command line tool.
  • dotnet user-secrets set SecondSecret Password
    Adds a new user secret with the key SecondSecret and value Password to your project.
  • dotnet user-secrets list
    lists all user secrets in your project.
  • dotnet user-secrets remove SecondSecret
    Removes SecondSecret from your project.
  • dot net user-secret clear
    Clears all secrets from your project.

Note

ASP.NET Core 2.0 Remove .AddUserSecrets() method, use builder.AddUserSecrets<Startup>(); method

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top