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
                            {}
                           
                    }

  • 相关阅读:
    TextOut和DrawText
    VC中字符串定义
    #define new DEBUG_NEW
    洛谷【P2257】 YY的GCD
    Lizards and Basements 2 解题报告
    在windows服务中添加WCF
    从数据库中获得表的字段和描述信息
    sql格式化工具
    在XPSP3中添允许多个远程桌面的步骤
    无法连接到WCF的异常
  • 原文地址:https://www.cnblogs.com/liubiqu/p/181104.html
Copyright © 2011-2022 走看看