What is the difference between app.UseHsts() and app.UseExceptionHandler()?

It is an old question but if you still didn't figure out the answer then this might help.

UseHsts adds a header Strict-Transport-Security to the response. When the site was accessed using HTTPS then the browser notes it down and future request using HTTP will be redirected to HTTPS. So, accessing the site using HTTPS at least once is mandatory to make this work.

Also the expiration time set by the Strict-Transport-Security header elapses, the next attempt to load the site via HTTP won't be automatically redirected to HTTPS.


Hsts is a security feature to force SSL. It has nothing to do with exceptions.

  • UseHsts
  • UseExceptionHandler

Tags:

C#

.Net

.Net Core