Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在ASP.NET中自动从HTTP切换到HTTPS_C#_Asp.net_Http_Https_Global Asax - Fatal编程技术网

C# 在ASP.NET中自动从HTTP切换到HTTPS

C# 在ASP.NET中自动从HTTP切换到HTTPS,c#,asp.net,http,https,global-asax,C#,Asp.net,Http,Https,Global Asax,如何在ASP.NET中自动从HTTP切换到HTTPS 也不需要在本地连接中执行相同的操作让我们开始: 打开Global.asax code finde应用程序\u BeginRequest,如下更改: protected void Application_BeginRequest(object sender, EventArgs e) { if (HttpContext.Current.Request.IsSecureConnection.Equals(

如何在ASP.NET中自动从HTTP切换到HTTPS

也不需要在本地连接中执行相同的操作

让我们开始:

打开Global.asax code finde应用程序\u BeginRequest,如下更改:

 protected void Application_BeginRequest(object sender, EventArgs e)
        {
            if (HttpContext.Current.Request.IsSecureConnection.Equals(false) && HttpContext.Current.Request.IsLocal.Equals(false))
            {
                Response.Redirect("https://" + Request.ServerVariables["HTTP_HOST"] + HttpContext.Current.Request.RawUrl);
            }
        }

宾果

这在IIS8中不起作用-有解决方案吗?