How to enable SSL / Https in a Visual Studio Web Api project

useful link is here:

https://dotnetcodr.com/2015/09/18/how-to-enable-ssl-for-a-net-project-in-visual-studio/

Create a new Web Api project in Visual Studio:

Select/click on the Web API project name in the solution explorer, and then click on the Properties tab. Set ‘SSL Enabled’ to true:

The same properties window will also show the HTTPS url for the application. In the above example it’s https://localhost:44314/. Copy that URL and go to the project properties window.

Navigate to the Web tab and override the Project Url property with the https address that you copied:

Build and run the application.

The likelihood is that a message appears in the browser saying that the localhost address is not trusted, you can continue to the website at your own risk. Here’s a Firefox example:

The problem is that the certificate automatically installed by Visual Studio is untrusted.

In the search programs and files, type ‘mmc’ (Microsoft Management Console):

Select File > Add/Remove Snap-in. Select Certificates > Add:

Select Computer account:

Click Finish and OK.

Locate the IIS certificate in the Personal folder of the computer-level certificates in the certificates snap-in.

The certificate must be imported into the trusted root certification authorities folder, shown below the folder just below “Personal”.

Right-click the certificate, then select All Tasks, Export… from the context menu.

Click Next on the certificate export wizard.

Leave the “Do not export the private key” option untouched, click Next.

Accept the default on the next screen, i.e. “DER encoded binary X.509” should stay selected, then click Next.

Then you’ll need to provide a name and a location for the exported file. Call it “localhost” and save it in a location where you can easily find it:

Click Next and then Finish.

There should be a popup message saying that the export was successful.

Now right-click the folder called Trusted Root Certification Authorities and select All Tasks, Import…

Browse to the certificate you saved just before.

Click Next and accept all the default values along the way until you reach the end of the wizard. There should be a message saying that the import was successful. You may have to add a security exception to get Firefox to run with this site…