Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How to bypass the locale selection page in your Commerce Server 2002 Retail Web site


View products that this article applies to.

Summary

The Retail2002 solution Web site that is included with Microsoft Commerce Server 2002 incorporates multilanguage and multiple Country/Region features. However, you may not want users to view the locale selection page when they visit your Web site.

This article discusses how to modify the code in the Application.cs file to bypass the locale selection page. After you modify the code, the user does not receive the prompt to "Select Country/Region and Language" the first time that the user visits the Web site. Instead, the application starts on the Web site's home page.

↑ Back to the top


More information

In the Application.cs file, the section of the code that sets the locale is in the Application_BeginRequest procedure. The following code is the part of this procedure sets the locale.
            //
            //  Get the current culture information for this request. This
            //  information comes from the current user's profile ticket.
            //

            CultureInfo cultureInfo = CommerceApplication.CurrentProfileCulture;

            if ( cultureInfo != null )
            {
                //
                //  Set the current thread context to this culture.
                //

                Thread.CurrentThread.CurrentCulture = cultureInfo;
                Thread.CurrentThread.CurrentUICulture = cultureInfo;
            }
         
			//
			//  Handle special-case documents 
			//

			string currentDocument = this.CurrentDocument;

            //
            //  Check to see if the current user has been authenticated before.
            //

            if ( CommerceContext.Current.AuthenticationInfo.IsAuthenticated() == false )
            {
                //
                //  This user has not been authenticated. Is this a new visitor to site?
                //

                string userID = AccountManager.ProfileTicketUserID;

				if ( userID == null )
				{
					//
					//	The profile ticket doesn't appear valid. Create a new anonymous user
					//	account to track this user.
					//

					AccountManager.CreateAnonymousUserAccount();
				}
            }
			
            //
            //  If the current document doesn't match the following
			//	criteria then go to the locale selection page and 
			//	get some answers.
            //
			
			if ( cultureInfo == null )
			{
				if ( currentDocument != "localeselection.aspx"	&& 
					 currentDocument != "customerror.aspx"		&& 
					 currentDocument != "notfound.aspx"			&& 
					 currentDocument != "bdrefresh.aspx"		&& 
					 currentDocument != "refreshapp.aspx"		&&
					 currentDocument != "passportlogin.aspx"	&&
					 currentDocument != "passportlogout.aspx"   &&
				     currentDocument != "logout.aspx"
					)
				{
					//
					//  Redirect to the locale selection page and on return
					//  redirect back to the calling page.
					//

					CommerceApplication.Redirect("localeselection.aspx", currentDocument, false);
				}
			}

            //
            //  Check for secure documents.
            //

            SecureDocument secureDocument = CommerceApplication.GetSecureDocument(currentDocument);
To bypass the locale selection process, follow these steps:
  1. In the Application.cs file, locate the procedure Application_BeginRequest.
  2. Locate the previous section of code in the procedure, and then replace that code with the following code.
                //
                //  Get the current culture information for this request. This
                //  information comes from the current user's profile ticket.
                //
    
                CultureInfo cultureInfo = CommerceApplication.CurrentProfileCulture;
    			string cultureName = "en-US";
    			CommerceApplication.CurrentProfileCulture = new CultureInfo(cultureName);
    			cultureInfo= new CultureInfo(cultureName);
    
                if ( cultureInfo != null )
                {
                    //
                    //  Set the current thread context to this culture.
                    //
    
                    Thread.CurrentThread.CurrentCulture = cultureInfo;
                    Thread.CurrentThread.CurrentUICulture = cultureInfo;
                }
             
    			//
    			//  Handle special-case documents 
    			//
    
    			string currentDocument = this.CurrentDocument;
    
                //
                //  Determine whether the current user has been authenticated before.
                //
    
                if ( CommerceContext.Current.AuthenticationInfo.IsAuthenticated() == false )
                {
                    //
                    //  This user has not been authenticated. Is this a new visitor to site?
                    //
    
                    string userID = AccountManager.ProfileTicketUserID;
    
    				if ( userID == null )
    				{
    					//
    					//	The profile ticket does not appear to be valid. Create a new anonymous user
    					//	account to track this user.
    					//
    
    					AccountManager.CreateAnonymousUserAccount();
    				}
                }
    			//
                //  Determine whether there are secure documents.
                //
    
                SecureDocument secureDocument = CommerceApplication.GetSecureDocument(currentDocument);
    
  3. Recompile the application, and then visit the Web site in your browser. Notice that the locale selection page does not appear.

↑ Back to the top


Keywords: KB812303, kbinfo, kbhowto

↑ Back to the top

Article Info
Article ID : 812303
Revision : 4
Created on : 1/2/2004
Published on : 1/2/2004
Exists online : False
Views : 322