Missing title when changing code in root.master.cs

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 年 前
Had this problem that the site title is not reflecting as set in admin page. Managed to narrow down to my root.master.cs. Any expert can advise? If i remove System.Data, System.Net and System.Xml, the title comes back.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using System.Xml;

namespace NopSolutions.NopCommerce.Web.MasterPages
{
    public partial class root : BaseNopMasterPage
    {

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //(for control in ContentPlaceHolder) ContentPlaceHolder cp = Page.Master.Master.FindControl("cph1") as ContentPlaceHolder;
                UserControl cp = FindControl("ctrlHeader$ctrlSearchBox") as UserControl;
                TextBox txt = cp.FindControl("txtSearchTerms") as TextBox;
                if (txt != null)
                {
                    txt.Attributes.Add("onclick", "txtboxSearch_Clear()");
                }

                UserControl cp2 = FindControl("ctrlHeader") as UserControl;
                Literal lit = cp2.FindControl("ipLocationText") as Literal;
                Image litimg = cp2.FindControl("ipLocationImg") as Image;
                lit.Text = "Shipping in Singapore only. <br /> <a href='http://www.testing.com"+Request.Url.PathAndQuery+"'>For International Shipping, click here</a>";
                litimg.ImageUrl = Page.ResolveUrl("~/images/image/flags/sg.gif");

                //Get IP Address
                string ipaddress;
                ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                if (ipaddress == "" || ipaddress == null)
                    ipaddress = Request.ServerVariables["REMOTE_ADDR"];

                DataTable dt = GetLocation(ipaddress);
                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {

                        if (dt.Rows[0]["CountryCode"].ToString() == "SGx")
                        //if (dt.Rows[0]["CountryCode"].ToString() != "SG")
                        {
                            Response.Redirect("http://www.testing.com"+Request.Url.PathAndQuery);
                        }
                        else
                        {

                        }
                    }
                    else
                    {

                    }
                }
            }
        }

        private DataTable GetLocation(string ipaddress)
        {
            //Create a WebRequest
            WebRequest rssReq = WebRequest.Create("http://freegeoip.appspot.com/xml/" + ipaddress);

            //Create a Proxy
            WebProxy px = new WebProxy("http://freegeoip.appspot.com/xml/" + ipaddress, true);

            //Assign the proxy to the WebRequest
            rssReq.Proxy = px;

            //Set the timeout in Seconds for the WebRequest
            rssReq.Timeout = 2000;
            try
            {
                //Get the WebResponse
                WebResponse rep = rssReq.GetResponse();

                //Read the Response in a XMLTextReader
                XmlTextReader xtr = new XmlTextReader(rep.GetResponseStream());

                //Create a new DataSet
                DataSet ds = new DataSet();

                //Read the Response into the DataSet
                ds.ReadXml(xtr);
                return ds.Tables[0];
            }
            catch
            {
                return null;
            }
        }

    }
}
14 年 前
Still can't solve this. Anyone encountered this before?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.