2024年3月7日发(作者:)

using ing;using ies;

namespace itcherPage{public class HTTPSwitcherModule : IHttpModule{///

/// You will need to configure this module in the file of your/// web and register it with IIS before being able to use it. For more information/// see the following link: /?linkid=8101007/// #region IHttpModule Members

public void Dispose(){//clean-up code here.}

///

/// Init event/// /// public void Init(HttpApplication context){// Below is an example of how you can handle Request event and provide// custom logging implementation for uestHandlerExecute += context_PreRequestHandlerExecute;}

#endregion

///

/// Assuming the selected language is stored in a cookie. Firstly, get the selected/// language from cookie. Then add the selected language to the request header./// Finally, use the selected language for the current culture./// /// /// void context_PreRequestHandlerExecute(object sender, EventArgs e){// Get current application.

HttpApplication httpApp = sender as HttpApplication;

// Get all HTTP-specific information about current HTTP ntext context = t;

// Current strLanguage = ;

// The key of current selected language in the strKeyName = "LangSwitcher_Setting";

try{// Set the current (s[strKeyName] != null){strLanguage = s[strKeyName].Value;}else{strLanguage = "zh-cn";}

var lang = s["Accept-Language"];if (lang != null){if (!ns(strLanguage))s["Accept-Language"] = strLanguage + "," + s["Accept-Language"];

var culture = new eInfo(strLanguage);

// Apply the eadCulture(culture, culture);}}catch (Exception ex){ine(e);}}}}