如何在IIS 6中启用SSL证书并在Global.asax下将http转换为https? [英] How to enable SSL certificate in IIS 6 and convert http to https under Global.asax?

查看:147
本文介绍了如何在IIS 6中启用SSL证书并在Global.asax下将http转换为https?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在IIS 6中启用SSL证书并在Global.asax下将http转换为https?也可以测试http到https自动重定向。我的意思是如果用户在启用SSL后键入http而不是https,则必须重定向到https。 Url Rewrite已经尝试过但没有用。另一个代码如下所示在Global.asax下并在Application_Begin请求下调用。

How to enable SSL certificate in IIS 6 and convert http to https under Global.asax? Also is it possible to test http to https auto redirection. I mean if user types http instead of https after SSL enabled it must redirect to https. Url Rewrite already tried but didn't work. Another code is as follows under Global.asax and called under Application_Begin Request.

private void RedirectToCorrectSSLScheme()
 {
     Uri pageRequest = Request.Url;
     string requestPath = pageRequest.GetLeftPart(UriPartial.Path).ToLower();

      requestPath = Server.UrlDecode(requestPath);
     // PageIsSecure returns if the given page should be secure or not. I
     //maintain a list of secure pages or
     //secure directory in an XML config.
   //  bool securePage = GetSecurePages().PageIsSecure(requestPath);
     //Instead of localhost we can set the IP Address of Dubai server
     if (pageRequest.Scheme == "https" && pageRequest.Host.Contains("localhost") && requestPath.Contains(".aspx"))
     {
         //Response.Redirect("http://" + pageRequest.Host + pageRequest.PathAndQuery, true);
         Response.Redirect(requestPath, true);
     }
     //Added by Alex to check  external url of qatar server
     //Instead of localhost we can set the IP Address of Dubai server
     if (pageRequest.Scheme == "http" && pageRequest.Host.ToString()!="localhost"  && requestPath.Contains(".aspx"))

     {
        //Response.Redirect("https://" + pageRequest.Host + pageRequest.PathAndQuery, true);

        Response.Redirect(requestPath, true);
     }
 }





问题仍然存在于本地。



Still the issue persists locally.

推荐答案

试试这个........



http://www.youtube.com/watch?v=gmxoC7HkylE&list=PL6n9fhu94yhXQS_p1i-HLIftB9Y7Vnxlo [ ^ ]
Try this........

http://www.youtube.com/watch?v=gmxoC7HkylE&list=PL6n9fhu94yhXQS_p1i-HLIftB9Y7Vnxlo[^]


这篇关于如何在IIS 6中启用SSL证书并在Global.asax下将http转换为https?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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