Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 我应该使用什么事件(地点)来更改多语言网站中的文化和日历?_C#_Asp.net_Culture_Global.asa - Fatal编程技术网

C# 我应该使用什么事件(地点)来更改多语言网站中的文化和日历?

C# 我应该使用什么事件(地点)来更改多语言网站中的文化和日历?,c#,asp.net,culture,global.asa,C#,Asp.net,Culture,Global.asa,我有一个多语言网站… 我在VisualStudio中为语言创建了两个文件夹(en+我的语言),并为每个文件夹创建了我的网站 对于一个语言网站,我有一个将文化和日历更改为我的文化的类,并在Global.asax中调用该类,如下所示: protected void Application_BeginRequest(object sender, EventArgs e) { myLanCultureAndCalendar.SetCultureAndCalendar(); } 但对于多语言网站

我有一个多语言网站…
我在VisualStudio中为语言创建了两个文件夹(en+我的语言),并为每个文件夹创建了我的网站
对于一个语言网站,我有一个将文化和日历更改为我的文化的类,并在Global.asax中调用该类,如下所示:

protected void Application_BeginRequest(object sender, EventArgs e)
{
    myLanCultureAndCalendar.SetCultureAndCalendar();
}
但对于多语言网站,我可以对该课程做些什么?
是指每种语言我应该在哪里调用该类?
我的页面基于母版页和内容页


正如你所知道的那样,
global.asax应用程序\u BeginRequest首先运行->之后我们有了内容页\u Load->最后是母版页\u Load

我认为你必须在应用程序\u BeginRequest事件中实现该类…如下

protected void Application_BeginRequest(Object sender, EventArgs e)
{
    String language = Request.UserLanguages[0];
    if (language.Length > 1) language = language.Substring(0, 2);
    .......
    ........

}
我建议你通过这个链接来获取更多信息


我希望它能帮助你..

谢谢你的回答/但是有没有其他不使用用户语言的方法?还有其他想法吗?在这个问题上使用用户的机器语言似乎不太好/我们可以使用会话或类似的东西吗?