且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检测浏览器的显示语言

更新时间:2021-09-10 22:14:58

设置的UICulture 文化的页面指​​令为我工作:

Setting the UICulture and Culture on the page directive worked for me:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1.Default" UICulture="auto" Culture="auto" %>

然后我把我的铬语言法国,并确保重新排序的语言 - 镶边将采取最上面的语言为默认浏览器

I then set my chrome language to French and made sure to re-order the languages - chrome will take the topmost language as default for the browser.

然后我用:

Response.Write(System.Threading.Thread.CurrentThread.CurrentUICulture);

这正确地给了我 FR

您可以设置页面级别的文化还是全球范围内,看到这里

You can set the culture on the page level or globally, see here.