Xử lý chuyển hướng http đến https trong aspx

Xử lý chuyển hướng http đến https trong aspx

Đoạn code chuyển hướng từ http sang https dành cho web aspx, c# chạy trên IIS

   string authority = Request.Url.Scheme +"://"+ Request.Url.Authority + Request.Url.AbsolutePath;
       
        if (authority.IndexOf("http:") == 0 )
        {
            Response.StatusCode = 301;
            authority = authority.Replace("http:","https:");
            Response.Redirect(authority, true);
           }

Xử lý chuyển hướng http đến https trong aspx