November Happy Hour will be moved to Thursday December 5th.

Language problem, language is reset to default when logging in

Vote:
 

Hi,

 

I’m having a problem with the language on my site. I want to be able to change language on the site and I’m having an asp dropdownlist through with the user can change language. The problem is that if I change the language before I log in the language is reset to the default language after I’ve logged in. This is not the case when I log out. If I’ve changed language when I was logged in that language is still set after logging out.

 

When we log in we’re using:

        protected void btnLogin_Click(object sender, EventArgs e)

        {

            if (UserHandler.loginUser(txtUsername.Text, txtPassword.Text))

            {

                Functions.GetFriendlyUrl("EPEHome");

                FormsAuthentication.RedirectFromLoginPage(txtUsername.Text, false);

                Functions.GetFriendlyUrl("EPEHome");

            }

            // If we reach here, the user's credentials were invalid

            divResultMessage.Visible = true;

        }

 

        public static bool loginUser(string username, string password)

        {

            bool result = false;

            if (Membership.ValidateUser(username, password))

            {

                result = true;

            }

 

            return result;

        }

 

When we log out we do it like this:

Response.Redirect(Functions.GetFriendlyUrl("EPEHome"));

 

Our friendlyUrl looks like this:

 

        public static string GetFriendlyUrl(String dynamicProperyPage)

        {

            PageBase pageBase = HttpContext.Current.Handler as PageBase;

            PageReference pageReference = pageBase.CurrentPage[dynamicProperyPage] as PageReference;

 

            if (pageReference != null)

            {

                EPiServer.UrlBuilder url = new EPiServer.UrlBuilder(DataFactory.Instance.GetPage(pageReference).LinkURL);

                EPiServer.Global.UrlRewriteProvider.ConvertToExternal(url, null, System.Text.UTF8Encoding.UTF8);

                string friendlyUrl = UriSupport.AbsoluteUrlBySettings(url.ToString());

                return friendlyUrl;

            }           

            return string.Empty; 

        }

 

If I change from default (English) to Swedish before logging in I can see that friendlyUrl() returns Swedish ("http://localhost:55502/sv”) both before and after calling FormsAuthentication.RedirectFromLoginPage() in btnLogin_Click() in Login.aspx.cs, but it returns English ("http://localhost:55502/en”) when I reach Home.aspx.cs.

 

To solve the problem I’ve tried the code snippet below. That didn’t work though and unfortunately it also made my logout fail. I was just redirected to Home and I was still logged in, instead of being logged out and redirected to the LoggedOut page.

 

EPiServer.UrlBuilder url = new EPiServer.UrlBuilder(pageBase.CurrentPage.LinkURL);

EPiServer.Global.UrlRewriteProvider.ConvertToExternal(url, pageBase.CurrentPage.PageLink, System.Text.UTF8Encoding.UTF8);

 

I’ve also tried to set defaultUrl="Util/Home.aspx" in web.config, since FormsAuthentication.RedirectFromLoginPage() redirects me to default.aspx otherwise but that did’t help. Could this perhaps even be part of the problem, that this link maybe does not support language changes?

 

Anybody encountered this problem before? I would be very thankful if someone could help me figure out what the problem is, why the language is changed to default language when I log in. I’m quite lost right now.

 

Thanks in advance!

 

Br, Sandra

#46444
Dec 13, 2010 10:24
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.