如何在IIS中启用SSL证书的情况下将http更改为https,以避免出现问题。 ? [英] How to avoid issues when changing http to https in asp.net with SSL cert enabled in IIS. ?

查看:424
本文介绍了如何在IIS中启用SSL证书的情况下将http更改为https,以避免出现问题。 ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IIS中启用SSL证书的情况下,如何在asp.net中将http更改为https时避免出现问题。 ?



有一个本地网络应该使用http(即使使用ssl证书)和外部网站即使https更改为http也应该工作。 Rt现在获取页面无法在浏览器中显示问题。



我在Globla.asax下尝试如下:

How to avoid issues when changing http to https in asp.net with SSL cert enabled in IIS. ?

There is a local network which should work with http also (even with ssl certificate) and external site which should workk even if https changed to http. Rt now getting page cannot be displayed issue in browser.

I tried under Globla.asax as follows:

void  Application_BeginRequest(object sender, EventArgs e)
 {

     // Code that runs on application startup

     //Function Added by Alex on Jan 30,2014 to clear http/https issue under Qatar Server
    // RedirectToCorrectSSLScheme();
     // test();
     string path = HttpContext.Current.Request.Url.AbsolutePath;
     if (HttpContext.Current.Request.ServerVariables["HTTPS"] == "on")
     {

         HttpContext.Current.Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri.Replace("http://", "https://"));
         return;
     }
     if (HttpContext.Current.Request.ServerVariables["HTTPS"] != "on")
     {

         HttpContext.Current.Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri.Replace("https://", "http://"));
         return;
     }

 }

推荐答案

为什么强制为本地网络强制建立非SSL连接?如果您为SSL配置了站点,则无论内部还是外部都使用它。
Why force a non-SSL connection for you local network? If you have the site configured for SSL use it regardless of internal or external.


这篇关于如何在IIS中启用SSL证书的情况下将http更改为https,以避免出现问题。 ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆