UserSecretsConfigurationExtensions.AddUserSecrets Method

Definition

Overloads

AddUserSecrets(IConfigurationBuilder, Assembly)

Adds the user secrets configuration source. This searches assembly for an instance of UserSecretsIdAttribute, which specifies a user secrets ID.

A user secrets ID is unique value used to store and identify a collection of secret configuration values.

AddUserSecrets(IConfigurationBuilder, String)

Adds the user secrets configuration source with specified user secrets ID.

A user secrets ID is unique value used to store and identify a collection of secret configuration values.

AddUserSecrets(IConfigurationBuilder, Assembly, Boolean)

Adds the user secrets configuration source. This searches assembly for an instance of UserSecretsIdAttribute, which specifies a user secrets ID.

A user secrets ID is unique value used to store and identify a collection of secret configuration values.

AddUserSecrets(IConfigurationBuilder, String, Boolean)

Adds the user secrets configuration source with specified user secrets ID.

A user secrets ID is unique value used to store and identify a collection of secret configuration values.

AddUserSecrets(IConfigurationBuilder, Assembly, Boolean, Boolean)

Adds the user secrets configuration source. This searches assembly for an instance of UserSecretsIdAttribute, which specifies a user secrets ID.

A user secrets ID is unique value used to store and identify a collection of secret configuration values.

AddUserSecrets<T>(IConfigurationBuilder)

Adds the user secrets configuration source. Searches the assembly that contains type T for an instance of UserSecretsIdAttribute, which specifies a user secrets ID.

A user secrets ID is unique value used to store and identify a collection of secret configuration values.

AddUserSecrets<T>(IConfigurationBuilder, Boolean)

Adds the user secrets configuration source. Searches the assembly that contains type T for an instance of UserSecretsIdAttribute, which specifies a user secrets ID.

A user secrets ID is unique value used to store and identify a collection of secret configuration values.

AddUserSecrets<T>(IConfigurationBuilder, Boolean, Boolean)

Adds the user secrets configuration source. Searches the assembly that contains type T for an instance of UserSecretsIdAttribute, which specifies a user secrets ID.

A user secrets ID is unique value used to store and identify a collection of secret configuration values.

AddUserSecrets(IConfigurationBuilder, Assembly)

Source:
UserSecretsConfigurationExtensions.cs
Source:
UserSecretsConfigurationExtensions.cs
Source:
UserSecretsConfigurationExtensions.cs

Adds the user secrets configuration source. This searches assembly for an instance of UserSecretsIdAttribute, which specifies a user secrets ID.

A user secrets ID is unique value used to store and identify a collection of secret configuration values.

C#
public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddUserSecrets(this Microsoft.Extensions.Configuration.IConfigurationBuilder configuration, System.Reflection.Assembly assembly);

Parameters

configuration
IConfigurationBuilder

The configuration builder.

assembly
Assembly

The assembly with the UserSecretsIdAttribute.

Returns

The configuration builder.

Exceptions

assembly does not have a valid UserSecretsIdAttribute.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

AddUserSecrets(IConfigurationBuilder, String)

Source:
UserSecretsConfigurationExtensions.cs
Source:
UserSecretsConfigurationExtensions.cs
Source:
UserSecretsConfigurationExtensions.cs

Adds the user secrets configuration source with specified user secrets ID.

A user secrets ID is unique value used to store and identify a collection of secret configuration values.

C#
public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddUserSecrets(this Microsoft.Extensions.Configuration.IConfigurationBuilder configuration, string userSecretsId);

Parameters

configuration
IConfigurationBuilder

The configuration builder.

userSecretsId
String

The user secrets ID.

Returns

The configuration builder.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

AddUserSecrets(IConfigurationBuilder, Assembly, Boolean)

Source:
UserSecretsConfigurationExtensions.cs
Source:
UserSecretsConfigurationExtensions.cs
Source:
UserSecretsConfigurationExtensions.cs

Adds the user secrets configuration source. This searches assembly for an instance of UserSecretsIdAttribute, which specifies a user secrets ID.

A user secrets ID is unique value used to store and identify a collection of secret configuration values.

C#
public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddUserSecrets(this Microsoft.Extensions.Configuration.IConfigurationBuilder configuration, System.Reflection.Assembly assembly, bool optional);

Parameters

configuration
IConfigurationBuilder

The configuration builder.

assembly
Assembly

The assembly with the UserSecretsIdAttribute.

optional
Boolean

Whether loading secrets is optional. When false, this method may throw.

Returns

The configuration builder.

Exceptions

optional is false and assembly does not have a valid UserSecretsIdAttribute.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

AddUserSecrets(IConfigurationBuilder, String, Boolean)

Source:
UserSecretsConfigurationExtensions.cs
Source:
UserSecretsConfigurationExtensions.cs
Source:
UserSecretsConfigurationExtensions.cs

Adds the user secrets configuration source with specified user secrets ID.

A user secrets ID is unique value used to store and identify a collection of secret configuration values.

C#
public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddUserSecrets(this Microsoft.Extensions.Configuration.IConfigurationBuilder configuration, string userSecretsId, bool reloadOnChange);

Parameters

configuration
IConfigurationBuilder

The configuration builder.

userSecretsId
String

The user secrets ID.

reloadOnChange
Boolean

Whether the configuration should be reloaded if the file changes.

Returns

The configuration builder.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

AddUserSecrets(IConfigurationBuilder, Assembly, Boolean, Boolean)

Source:
UserSecretsConfigurationExtensions.cs
Source:
UserSecretsConfigurationExtensions.cs
Source:
UserSecretsConfigurationExtensions.cs

Adds the user secrets configuration source. This searches assembly for an instance of UserSecretsIdAttribute, which specifies a user secrets ID.

A user secrets ID is unique value used to store and identify a collection of secret configuration values.

C#
public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddUserSecrets(this Microsoft.Extensions.Configuration.IConfigurationBuilder configuration, System.Reflection.Assembly assembly, bool optional, bool reloadOnChange);

Parameters

configuration
IConfigurationBuilder

The configuration builder.

assembly
Assembly

The assembly with the UserSecretsIdAttribute.

optional
Boolean

Whether loading secrets is optional. When false, this method may throw.

reloadOnChange
Boolean

Whether the configuration should be reloaded if the file changes.

Returns

The configuration builder.

Exceptions

optional is false and assembly does not have a valid UserSecretsIdAttribute.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

AddUserSecrets<T>(IConfigurationBuilder)

Source:
UserSecretsConfigurationExtensions.cs
Source:
UserSecretsConfigurationExtensions.cs
Source:
UserSecretsConfigurationExtensions.cs

Adds the user secrets configuration source. Searches the assembly that contains type T for an instance of UserSecretsIdAttribute, which specifies a user secrets ID.

A user secrets ID is unique value used to store and identify a collection of secret configuration values.

C#
public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddUserSecrets<T>(this Microsoft.Extensions.Configuration.IConfigurationBuilder configuration) where T : class;

Type Parameters

T

The type from the assembly to search for an instance of UserSecretsIdAttribute.

Parameters

configuration
IConfigurationBuilder

The configuration builder.

Returns

The configuration builder.

Exceptions

The assembly containing T does not have UserSecretsIdAttribute.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

AddUserSecrets<T>(IConfigurationBuilder, Boolean)

Source:
UserSecretsConfigurationExtensions.cs
Source:
UserSecretsConfigurationExtensions.cs
Source:
UserSecretsConfigurationExtensions.cs

Adds the user secrets configuration source. Searches the assembly that contains type T for an instance of UserSecretsIdAttribute, which specifies a user secrets ID.

A user secrets ID is unique value used to store and identify a collection of secret configuration values.

C#
public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddUserSecrets<T>(this Microsoft.Extensions.Configuration.IConfigurationBuilder configuration, bool optional) where T : class;

Type Parameters

T

The type from the assembly to search for an instance of UserSecretsIdAttribute.

Parameters

configuration
IConfigurationBuilder

The configuration builder.

optional
Boolean

Whether loading secrets is optional. When false, this method may throw.

Returns

The configuration builder.

Exceptions

optional is false and the assembly containing T does not have a valid UserSecretsIdAttribute.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

AddUserSecrets<T>(IConfigurationBuilder, Boolean, Boolean)

Source:
UserSecretsConfigurationExtensions.cs
Source:
UserSecretsConfigurationExtensions.cs
Source:
UserSecretsConfigurationExtensions.cs

Adds the user secrets configuration source. Searches the assembly that contains type T for an instance of UserSecretsIdAttribute, which specifies a user secrets ID.

A user secrets ID is unique value used to store and identify a collection of secret configuration values.

C#
public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddUserSecrets<T>(this Microsoft.Extensions.Configuration.IConfigurationBuilder configuration, bool optional, bool reloadOnChange) where T : class;

Type Parameters

T

The type from the assembly to search for an instance of UserSecretsIdAttribute.

Parameters

configuration
IConfigurationBuilder

The configuration builder.

optional
Boolean

Whether loading secrets is optional. When false, this method may throw.

reloadOnChange
Boolean

Whether the configuration should be reloaded if the file changes.

Returns

The configuration builder.

Exceptions

optional is false and the assembly containing T does not have a valid UserSecretsIdAttribute.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)