Search code examples
c#.net.net-core

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


On the Startup.cs file of an .NET Core app, by default it make use of

    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseHsts();
        }

But in some cases I can find the use of

    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseExceptionHandler();
        }

What is the difference?


Solution

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