More in this section

Forums / General Discussions / How to set RequireSssl Property Programmatically from Master template

How to set RequireSssl Property Programmatically from Master template

2 posts, 0 answered
  1. Ben
    Ben avatar
    35 posts
    Registered:
    24 Jan 2011
    30 Mar 2011
    Link to this post
    What I'd like to do is (pseudo code from the master page template):

    1.if (_forceSSL && (!Request.IsLocal) && (!Request.IsSecureConnection))
    2.            {
    3.                //override sitefinity requireSSL checkbox in admin   
    4.                Page.RequireSsl = true; //HOW DO I DO THIS?
    5.  
    6.                //redirect page
    7.                Response.Redirect(Request.Url.ToString().Replace("http://", "https://"));
    8.            }

    Line 4. is what I'm stuck on. I don't know how to access the sitefinity property from inside the master page c# code.

    I looked at other forum threads and I figure it has something to do with the PageData object, but I don't know how to instantiate that with the correct page id from my master page. I'm using SF 4.0 and I believe we have the latest service pack installed.

    Thanks in advance for your help!

    Ben Barreth
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    18 Apr 2011
    Link to this post
    Hi Ben,

    You should work with PageData object and its RequireSsl property. PageData stores the page information/data for each PageNode. You can get a page node using the fluent or standard API.
    After you set the RequireSsl property you should call SaveChanges() method of the PageManager ( if you use the standard API or SaveChanges() from the fluent facade)

    Kind regards,
    Ivan Dimitrov
    the Telerik team

2 posts, 0 answered