asp.net - 无法为网站禁用 SSL

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

我创建了一个网站并将其部署到 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

最佳答案

好吧,我终于找到了解决方案。 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。手动删除它解决了问题。

关于asp.net - 无法为网站禁用 SSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18338368/

相关文章:

c# - 如何拦截页面中的任何回发? - ASP.NET

C++ 字符串在多行上打印

windows - 将代码从 Linux 移植到 Windows

asp.net-mvc-4 - 当 FileResult 函数在 MVC4 中运行时如何显示 'in progress'

c# - resx 文件未部署

c# - Ajax 更新面板不允许 javascript 在服务器端工作?

asp.net - jQuery黑莓ajax问题

c# - 在 Visual Studio 中使用自定义构建配置

c# - HTML5 视频的 ASP.NET MVC4 媒体源 Url

接受 List<CustomObject> 的 ASP.NET Web 方法失败,错误代码为 "Web Service method name is not valid."