Enable HSTS in server 2016 and IIS10 version 1607

Vindhya DS 1 Reputation point
2022-01-31T12:36:07.203+00:00

169867-hstsiiserror.png169850-config.xml

Hi
Please help me to enable HSTS server 2016 and IIS 10 version 1607.I have tried adding the below code to web config but it is throwing error, I have attached web config and error

<system.webServer>
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
<outboundRules>
<rule name="Add Strict-Transport-Security when HTTPS" enabled="true">
<match serverVariable="RESPONSE_Strict_Transport_Security" pattern=".
" />
<conditions>
<add input="{HTTPS}" pattern="on" ignoreCase="true" />
</conditions>
<action type="Rewrite" value="max-age=31536000; includeSubDomains; preload" />
</rule>
</outboundRules>
</rewrite>
</system.webServer>

Internet Information Services
{count} votes