jary dst
jary dst

Reputation: 23

asp user secret problem after publish project

my connection string in user secret No problem at local but is publish and upload in server error

ArgumentNullException: Value cannot be null. (Parameter 'connectionString')

Upvotes: 1

Views: 1879

Answers (4)

Apurba A
Apurba A

Reputation: 168

User secrets are not uploaded to azure, so you need to manually add them if you want to use.

  1. Go to azure projects dashboard
  2. Explore your project
  3. Open Configuration tab
  4. Add your configuration key and value
  5. Save it
  6. It will republish automatically and your app will be able to use secret keys

If any confusion, please comment.

Upvotes: 0

Hamed
Hamed

Reputation: 11

User secrets used for development security and it doesn't transfer/publish with your app (to GitHub or to IIS), they are stored in your local profile. If you are looking for securing your credentials & sensitive data the better way is to use Azure Key Vault (see Manage User Secrets)

Upvotes: 0

Nan Yu
Nan Yu

Reputation: 27588

user secrets is only for development and not intended for production.It doesn't encrypt the stored secrets and stored in a JSON configuration file in the user profile directory.

For production , usually you can use JSON file(appsettings.json/appsettings.{Environment}.json), environment variables, and Azure Key Vault(which is recommended), please read below article for more details about configuration providers in asp.net core :

Configuration in ASP.NET Core

Upvotes: 3

OO7
OO7

Reputation: 690

It seems the connectionStrings section is not yet configured at production machine. So you must store connection strings into Web.config file at production machine.

Connection Strings and Configuration Files

Besides that, you can protect the configuration by encrypt it using protected configuration.

Encrypting Configuration Information Using Protected Configuration

Upvotes: 0

Related Questions