如何在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[^]