zoukankan      html  css  js  c++  java
  • 在.Net里取得浏览器客户端的语言区域信息

    用这个可以取到用户的语言区域,
            strCulture = System.Threading.Thread.CurrentThread.CurrentUICulture.ToString();
            if(strCulture == "zh-TW")
            {
               LangID = "ChineseBG18030";
            }
            else if(strCulture == "zh-CN")
            {
               LangID = "Chinese(GB2312)";
            }
            else
            {
               LangID = "English";
            }

    但要在 Global.asax.cs里增加一段代码才可以不然就不行。
                    protected void Application_BeginRequest(Object sender, EventArgs e)
                    {
                            //为当前用户配置Culture
                            string strLang = "zh-cn";
                            if(this.Request.UserLanguages != null && this.Request.UserLanguages.Length>0)
                                    strLang = Request.UserLanguages[0];
                            System.Globalization.CultureInfo culture=new System.Globalization.CultureInfo(strLang);
                            System.Threading.Thread t=System.Threading.Thread.CurrentThread;
                            try
                            {
                                    t.CurrentUICulture=culture;//这个决定ResourceManager读取资源的行为
                            }
                            catch
                            {}
                           
                    }

  • 相关阅读:
    IDEA创建一个javaweb工程(在module中)以及配置Tomcat
    晨会复盘
    cnblog 笔记思路
    Mysql执行计划-extra
    Mysql执行计划分析-type(access_type)
    Mysql执行计划-selectType
    刻意训练
    MYSQL执行计划
    个人展望-程序员职业规划
    服务拆分原则
  • 原文地址:https://www.cnblogs.com/liubiqu/p/181104.html
Copyright © 2011-2022 走看看