You don't have access to this class

Keep learning! Join and start boosting your career

Aprovecha el precio especial y haz tu profesi贸n a prueba de IA

Antes: $249

Currency
$209
Suscr铆bete

Termina en:

1 D铆as
9 Hrs
35 Min
51 Seg

Tips de seguridad para almacenamiento en .NET Core

7/22
Resources

How to protect your information when developing .NET applications?

The development of .NET applications requires special attention to data security, particularly in the handling of connection strings. These strings are vital for accessing databases, queues, blobs, among others, and their protection is crucial when working in test or production environments. Here's how you can secure connection strings and strengthen the security of your applications using .NET.

Why choose .NET as a development platform?

.NET, especially when talking about .NET Core, is a robust platform created by Microsoft that leads with updates and new features. This ecosystem allows developers to work efficiently with multiple programming languages. Despite the syntactic differences between languages such as Python and C#, .NET features offer intuitive integration, ensuring that developers can perform similar tasks regardless of the language selected.

How to start your project development in .NET?

When getting started with .NET, it is first essential to set up a project. Here's how to create a console application that will serve as a basis for unifying future tasks and projects:

  1. Create a console project:

    dotnet new console -n BlogConsole

    This command creates a new console application called "BlogConsole".

  2. Locate yourself in the project directory:Make sure you enter the correct directory, paying attention to upper and lower case:

    cd BlogConsole
  3. Set up the basics of your application:Once inside the project, you will see a basic structure of a console application. From here you can start working on the development of specific functionalities.

How to manage and protect connection strings?

To hide the connection strings and protect them from prying eyes in your code, it is recommended to use JSON files to manage them in a more secure way.

  1. Create a settings file:Generate a JSON file to store the connection strings:

    { "ConnectionStrings": { "DefaultConnection": "your_connection_string_here" }}
  2. Add and configure required packages:To handle configurations, install the following packages:

    • Microsoft.Extensions.Configuration: helps read configurations.
    • Microsoft.Extensions.Configuration.Json: Facilitates the use of JSON files for configuration.

    You can search and install them using the .NET package manager:

    dotnet add package Microsoft.Extensions.Configurationdotnet add package Microsoft.Extensions.Configuration.Json

How to integrate the configuration into your application?

Once you have added the packages, you must make sure to implement the configurations in your project properly. This is achieved by reading the configurations from the JSON file and applying them inside your .NET application.

  1. Configure the configuration reader:You can set up a configuration reader in the Main method of your console application as follows:

    using Microsoft.Extensions.Configuration;
    var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);    
    IConfigurationRoot configuration = builder.Build();
    string connectionString = configuration.GetConnectionString("DefaultConnection");

This approach helps keep your connection strings secure and makes them easy to maintain and update. Always remember to check security practices when deploying an application to production, and always consider using the most stable versions of any additional packages.

With these steps, you will be more prepared to move forward in developing secure .NET applications. Never stop learning and continually improve your skills!

Contributions 9

Questions 2

Sort by:

Want to see more contributions, questions and answers from the community?

Para crear un proyecto de consola:
dotnet new console -n nombreProyecto

Paquetes instalados:

  • Microsoft.Extensions.Configuration:
    dotnet add package Microsoft.Extensions.Configuration --version 2.2.0
  • Microsoft.Extensions.Configuration.FileExtensions:
    dotnet add package Microsoft.Extensions.Configuration.FileExtensions --version 2.2.0

Configuraci贸n del proyecto

<ItemGroup>
    <None Update="appsettings.json">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>

Puedes Agregar los siguientes
Para netCore 3.1

dotnet add package Microsoft.Extensions.Configuration --version 3.1.4
dotnet add package Microsoft.Extensions.Configuration.FileExtensions --version 3.1.4

En la terminal

dotnet new console -n blobConssol``` 

cd BLobConsole 


Esta desactualizad铆simo el curso

Para los que usen .net core 6.0 o superior los Nuget Packages a instalar son los siguientes:

Microsoft.Extensions.Configuration ver 6.0.0
Microsoft.Extensions.Configuration.FileExtensions ver 6.0.0

avoid some sintaxError using @id:ms-vscode.csharp or https://github.com/OmniSharp/omnisharp-vscode

buen curso

Interesante!!