Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David 7 posts 27 karma points
    Aug 13, 2010 @ 17:37
    David
    0

    Redirecting by getting the Language of the Browser with a .NET Control

    why is this not working? I made a .Net Control with a redirect...

    why it didn't work? Can someone help me, please?


    [code]
     protected void Page_Load(object sender, EventArgs e)
            {
                redirectUrl();
            }


            public String GetLanguageOfBrowser()
            {
                #region WebSprachErkennung

                String strLanguage = String.Empty;

                // Sprache den Client Browser erkennen
                if (Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"] != null)
                {
                    strLanguage = Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"];
                   
                    strLanguage = strLanguage.ToLower();
                   
                }
                else
                {
                    strLanguage = "de";
                }
                    Session["MemberLanguage"] = strLanguage;

                return strLanguage;
                   
                #endregion // WebSprachErkennung
               
            }

            public void redirectUrl()
            {
                String ch_de_URL = "http://www.website.ch/1.aspx";
                String ch_fr_URL = "http://www.website.ch/2.aspx";
                String ch_it_URL = "http://www.website.ch/3.aspx";
                String ch_en_URL = "http://www.website.ch/4.aspx";


                // Select
                switch (GetLanguageOfBrowser())
                {
                    case "ch-de":
                        Response.Redirect(ch_de_URL);
                        break;
                    case "ch-fr":
                        Response.Redirect(ch_fr_URL);
                        break;
                    case "ch-it":
                        Response.Redirect(ch_it_URL);
                        break;
                    case "ch-en":
                        Response.Redirect(ch_en_URL);
                        break;
                    case "en":
                        Response.Redirect(ch_en_URL);
                        break;
                    default:
                        Response.Redirect(ch_en_URL);
                        break;
                }

     

            }
    [/code]

Please Sign in or register to post replies

Write your reply to:

Draft