C# 在ASP.NET中自动从HTTP切换到HTTPS
如何在ASP.NET中自动从HTTP切换到HTTPS 也不需要在本地连接中执行相同的操作让我们开始: 打开Global.asax code finde应用程序\u BeginRequest,如下更改: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(
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中不起作用-有解决方案吗?