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



The information in this article applies to:

  • Microsoft Commerce Server 2002
  • Microsoft Commerce Server 2002 SP2

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.

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.

Modification Type:MinorLast Reviewed:1/2/2004
Keywords:kbhowto kbinfo KB812303 kbAudDeveloper kbAudEndUser