【问题标题】:Unable to disable SSL for website无法为网站禁用 SSL
【发布时间】:2013-08-22 16:48:05
【问题描述】:

我创建了一个网站并将其部署到 Windows Azure。在开发过程中的某个地方,我从项目属性中启用了 SSL,并且所有内容(https 地址)在 localhost 和我部署网站的 Azure 网站上都运行良好。

现在我的 Azure 试用期即将到期,我正在将我的网站转移到另一个不支持 SSL 的免费 asp.net 托管,无需付费。

所以我认为这会很容易,只需将 SSL Enabled 设置回 False,就像我刚开始开发时一样,一切都很好,但事实并非如此。

禁用 SSL 后,我的网站无法运行。 我的 IIS Express 的 Visual Studio 设置图片打开并显示正确地址上有一个服务器:http://db.tt/EKTcxPsd

当我从 Visual Studio 启动站点时,它开始加载页面 localhost:44300。 几秒钟后,我被重定向到https://localhost,显示“网页不可用”错误。图片:http://db.tt/VntZTpKD

我已尝试删除 IISExpress 文件夹并重新启动 Visual Studio。重新创建的 applicationhost.config 文件具有正确的信息(据我所知)

<site name="PrototypeNew-bootstrap3" id="2">
  <application path="/" applicationPool="Clr4IntegratedAppPool">
    <virtualDirectory path="/" physicalPath="E:\path-shortened\Visual Studio 2013\Projects\PrototypeNew\PrototypeNew-branch" />
  </application>
  <bindings>
    <binding protocol="http" bindingInformation="*:44300:localhost" />
  </bindings>
</site>

将网站发布到托管环境后,我遇到了同样的问题。 转到http://mywebsite.com 会将我重定向到https://mywebsite.com 并显示与本地主机页面相同的错误。

如果我重新启用 SSL,那么我的本地主机上的 https 地址开始正常工作。

有人知道这里发生了什么吗?是否有另一个我忘记关闭的 SSL 开关?为什么它总是将我重定向到 https

编辑。尝试创建一个新的 asp.net mvc 4 项目。启动它,它工作正常。将 web.config 复制到我的项目中,它仍然重定向到 https:localhost

【问题讨论】:

  • 您的 web.config 中是否有 URL 重写规则以将所有 http 流量重定向到 https?
  • 好像我有,但我没有。我只是尝试调试并在 Global.asax.cs Application_Start() 中放置了一个断点。断点被命中,离开方法后页面重定向

标签: asp.net visual-studio asp.net-mvc-4 iis


【解决方案1】:

好的,我终于找到了解决方案。 FilterConfig.cs 如下所示:

public static void RegisterGlobalFilters(GlobalFilterCollection filters)
    {
        filters.Add(new HandleErrorAttribute());
        filters.Add(new System.Web.Mvc.AuthorizeAttribute());
        filters.Add(new RequireHttpsAttribute()); // problem
    }

它一定是在我启用 SSL 时自动添加了 RequireHttpsAttribute,然后没有删除它。手动删除它可以解决问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-30
    • 2014-12-10
    • 1970-01-01
    • 1970-01-01
    • 2017-11-12
    • 2018-09-15
    • 2015-07-28
    相关资源
    最近更新 更多