Where to place code in master.cs

Apr 6, 2011 at 6:24 PM
Edited Apr 6, 2011 at 7:21 PM

Where does one place this code in my master.cs file below?  Thank you.

 

protected void Page_PreRender(object sender, EventArgs e)
{
    if (phSidebar.Visible)
        Form1.Attributes.Add("class", "body");
    else
        Form1.Attributes.Add("class", "body noSidebar");
}

 

 

master.cs

 

 

public partial class BlueHorizon : System.Web.UI.MasterPage


{
    protected void Page_Load(object sender, EventArgs e)



    {
        //Check url for localhost or live
        string url = BlogEngine.Core.Utils.AbsoluteWebRoot.AbsoluteUri.ToString();
        //If live
        if (!url.ToLower().Contains("localhost"))
        {
            //Check for www. in the url "SEO friendly"
            if (!url.ToLower().Contains("www"))
            {
                string[] seourl = BlogEngine.Core.Utils.AbsoluteWebRoot.AbsoluteUri.ToString().Split(("/.").ToCharArray());
                HttpContext.Current.Response.Status = "301 Moved Permanently";
                HttpContext.Current.Response.AddHeader("Location", Request.Url.ToString().ToLower().Replace("http://", "http://www."));
            }
        }




        //This code is made by http://www.onesoft.dk
        if (Page.User.Identity.IsAuthenticated)
        {
            aLogin.InnerText = Resources.labels.logoff;
            aLogin.HRef = BlogEngine.Core.Utils.RelativeWebRoot + "Account/login.aspx?logoff";
        }
        else
        {
            aLogin.HRef = BlogEngine.Core.Utils.RelativeWebRoot + "Account/login.aspx";
            aLogin.InnerText = Resources.labels.login;
        }
    }
   
}

Solved