+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Detect Admin panel

Detect Admin panel

4 posts, 0 answered
  1. vinamra
    vinamra avatar
    45 posts
    Registered:
    23 Oct 2012
    17 Nov 2011
    Link to this post
    Hi

    i am using sitefinity 3.7 

    i want  to detect weather it is admin panel or live site.

    i have coded a ip to country specific site.


    now when i login in to admin panel i redirected to the country specific site.

    the redirection code is written in global.ascx

    so i want to check in global.ascx weather the request is for admin panel or live site.

    kindly help.
    thanks

  2. vinamra
    vinamra avatar
    45 posts
    Registered:
    23 Oct 2012
    18 Nov 2011
    Link to this post
    Kindly help 

    advice some code......


    thanks
  3. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    02 Dec 2016
    22 Nov 2011
    Link to this post
    Hello Vinamra,

    Can you please let us know how you've implemented your IP->Language version redirection code, so we can give you a more specific advice? Are you using an HttpHandler for that purpose? Generally, you can prevent code from running in edit mode by checking if the control is in desing mode:
    protected override void InitializeControls(GenericContainer container)
    {
        if (this.IsDesignMode())
        {
            //do something
        }
    }


    Kind regards,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  4. vinamra
    vinamra avatar
    45 posts
    Registered:
    23 Oct 2012
    23 Nov 2011
    Link to this post
    Hi i am using this code in global.ascx

    void Application_BeginRequest(object sender, EventArgs e)
       {
            Telerik.Cms.Web.CmsPageBase page = this.Page as Telerik.Cms.Web.CmsPageBase;
           if (page.PageMode != Telerik.Cms.Web.CmsPageMode.Edit)
           {
               string userHostIpAddress = HttpContext.Current.Request.UserHostAddress;
               System.Net.IPAddress ipAddress;
               if (System.Net.IPAddress.TryParse(userHostIpAddress, out ipAddress))
               {
                   // string country = ipAddress.Country(); // return value: UNITED STATES
                   string iso3166TwoLetterCode = ipAddress.Iso3166TwoLetterCode(); // return value: IN     this  is an extension method
                   if (iso3166TwoLetterCode == "IN")
                   {
                       HttpContext.Current.Response.Status = "301 Moved Permanently";
                       HttpContext.Current.Response.AddHeader("Location", "http://in." + GetServerDomain() + HttpContext.Current.Request.RawUrl);
                   }
                }
           }
       }


    i am running different sitefinity for different country.
    kindly guide if there is any better way of doing this in community edition.

    actually the problem is that when i login into admin panel this code redirect to country specific admin panel. now if i want to change the content of any other country website then i have to comment this code.
Register for webinar
4 posts, 0 answered