asp.net怎么调度线程的?
Zig 2003-05-04 01:35:41 如下代码,为了国际化设计的:
global.asax:
protected void Application_BeginRequest(Object sender, EventArgs e)
{
try
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(Request.UserLanguages[0]);
}
catch(Exception)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
}
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.Name = "lala";
}
protected void Application_Start(Object sender, EventArgs e)
{
Application["rm"] = ResourceManager.CreateFileBasedResourceManager("langtest",
Server.MapPath("Resources")+ Path.DirectorySeparatorChar,
null);
}
test.aspx
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
Label1.Text = ((ResourceManager)Application["rm"]).GetString("aaa");
}
无论我客户端的ie中设置什么显示的都是zh-cn的东西。
经过跟踪发现,
Application_BeginRequest中
Request.UserLanguages[0] = "en-US"
执行后
CurrentThread.CurrentCulture.Name = "en-US";
CurrentThread.Name = "lala";
但执行到Page_Load时
CurrentThread.CurrentCulture.Name = "zh-CN";
CurrentThread.Name = "lala";
这是怎么回事?!