...

/

Testing and Securing the Website

Testing and Securing the Website

Learn about testing ASP.NET Core empty website functionality and enabling HTTPS encryption for secure communication.

Test the functionality of the project and enable encryption

We will test the functionality of the ASP.NET Core Empty website project. We will also enable encryption of all traffic between the browser and web server for privacy by switching from HTTP to HTTPS. HTTPS is the secure encrypted version of HTTP.

Step 1: For Visual Studio:

  1. In the toolbar, make sure that the https profile is selected rather than http, IIS Express, or WSL, and change the Web Browser (Microsoft Edge) to Google Chrome, as shown in the figure:

Press + to interact
Selecting the https profile with its Kestrel web server in Visual Studio
Selecting the https profile with its Kestrel web server in Visual Studio
  1. Navigate to the “Debug | Start Without Debugging…” option.

  2. The first time we start a secure website, we will be prompted that our project is configured to use SSL, and to avoid warnings in the browser, we can choose to trust the self-signed certificate that ASP.NET Core has generated. Click the “Yes” button.

  3. When we see the “Security Warning” dialog box, click “Yes” again.

Step 2: For Visual Studio Code, enter the command to start the project with the https profile like this:

Press + to interact
dotnet run --launch-profile https

Then, start the browser.

Step 3: In either ...