ASP.NET Core redirect http to https

前端 未结 6 1565
陌清茗
陌清茗 2021-01-01 17:11

I have created a redirect rules in my web.config to redirect my website from http to https. The issue i have is that every single link on the website is now https. I have a

6条回答
  •  有刺的猬
    2021-01-01 17:42

    Actually (ASP.NET Core 1.1) there is a middleware named Rewrite that includes a rule for what you are trying to do.

    You can use it on Startup.cs like this:

    var options = new RewriteOptions()
        .AddRedirectToHttpsPermanent();
    
    app.UseRewriter(options);
    

提交回复
热议问题