Method 1: Using IIS Manager GUI
Open IIS Manager:
Select Your Website:
In IIS Manager, expand the server node and select your website.
HTTP Response Headers:
Double-click on the HTTP Response Headers icon in the website Home pane.
Add a Custom Header:
In the Actions pane (on the right), click on Add....
Enter Strict-Transport-Security as the name.
Enter max-age=31536000 (or your preferred value in seconds) as the value. This specifies how long HSTS is enforced (e.g., one year).
Apply Changes:
Click OK to save the header.
Restart the Website:
Restart your website to apply the changes.
Method 2: Using Web.config file
Search for system.webServer and add below configuration under customHeaders
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Strict-Transport-Security" value="max-age=31536000" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>