locked
.Net fuctions for SSL checks returning wrong results RRS feed

  • Question

  • User1953081067 posted

    Hi,

    I've tried using both the following:

    bool bIsSecure = HttpContext.Current.Request.IsSecureConnection;
    
    string sCheckHTTPs = Page.Request.Url.Scheme;

    The page is secure (SSL working fine), but the results are false for the first and HTTP for the second?

    Any ideas why it's returning an incorrect result?

    I'm using ASP.NET web forms 4.5.2

    Thanks as always

    Sunday, June 16, 2019 9:15 PM

All replies

  • User283571144 posted

    Hi RichardLaw,

    The page is secure (SSL working fine), but the results are false for the first and HTTP for the second?

    Any ideas why it's returning an incorrect result?

    According to your description, I have created a test demo on my side, it works well.

    I have enabled the SSL in the visual studio and use the https url  to access the web form site.

    I suggest you could post more about how you enable the SSL for your web application.

    If you could post more details information, it will be more easily for us to reproduce the issue and find out the solution.

    My test web form page code-behind:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace EmptyWebFormTest
    {
        public partial class SSLTest : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                bool bIsSecure = HttpContext.Current.Request.IsSecureConnection;
    
                string sCheckHTTPs = Page.Request.Url.Scheme;
                int i = 0;
            }
        }
    }

    Result:

    Best Regards,

    Brando

    Monday, June 17, 2019 2:01 AM