The purpose of using this is to keep the secured values outside of the code to avoid check in by mistake.
- Modify the .csproj file and add following "Microsoft.Extensions.SecretManager.Tools"
- Save and close.
- Right click the project and select "Manage User Secrets"
- this will open JS. store your secret values in there. This json file is stored away from the project on local machine.
- Add following into your Startup.cs file.
if (_hostingEnvironment.IsDevelopment())
{
builder.AddUserSecrets<Startup>();
}
- read the secret using Configuration. like if the secret name is "MySecret", read it like Configuration["MySecret"]
-This should only be used in development.
- For production, code will read the value from appsettings.json.
- Modify the .csproj file and add following "Microsoft.Extensions.SecretManager.Tools"
- Save and close.
- Right click the project and select "Manage User Secrets"
- this will open JS. store your secret values in there. This json file is stored away from the project on local machine.
- Add following into your Startup.cs file.
if (_hostingEnvironment.IsDevelopment())
{
builder.AddUserSecrets<Startup>();
}
- read the secret using Configuration. like if the secret name is "MySecret", read it like Configuration["MySecret"]
-This should only be used in development.
- For production, code will read the value from appsettings.json.
It's usefull blog,Thanks for sharing
ReplyDeleteDot Net Online Course Hyderabad
Thanks for sharing such informative guide on .Net technology. This post gives me detailed information about the .net technology. I am working as trainer in leading IT training academy offering Dot Net Training in Chennai
ReplyDeleteDot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery