【问题标题】:Redirects http to https in ASP.NET 1.1在 ASP.NET 1.1 中将 http 重定向到 https
【发布时间】:2013-03-20 05:02:26
【问题描述】:

每当使用 http 请求时,我想使用 https 重定向回页面。

我用过这段代码:

bool isSecure = false;
isSecure = Request.IsSecureConnection;

if(!isSecure)
{
    string redirectUrl = Request.Url.ToString().Replace("http:", "https:");
    Response.Redirect(redirectUrl);
}

页面示例如下

请求的页面:http://google.com/test.aspx?id=12233

重定向回:https://google.com/test.aspx?id=12233

目前它指向相同:http://google.com/test.aspx?id=12233 并显示错误:Internet Explorer 无法显示网页

我正在测试的网站目前没有经过 SSL 认证..但我的问题是..它不应该将页面重定向到 https,然后显示错误

【问题讨论】:

    标签: asp.net .net https


    【解决方案1】:

    HTTPS 默认端口是 443

    如果在您的服务器上的 443 端口上没有服务侦听,重定向将立即失败。我猜地址栏中 url 的更新将取决于浏览器。

    【讨论】:

      猜你喜欢
      • 2017-09-05
      • 1970-01-01
      • 2020-04-21
      • 2011-09-28
      • 2011-07-15
      • 1970-01-01
      • 2017-11-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多