【发布时间】:2012-03-07 07:33:14
【问题描述】:
我在我的项目中使用CultureModule.cs 根据我的变量值设置文化信息。这是一个例子
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Globalization;
namespace CwizBankApp
{
public class CultureModule:IHttpModule
{
public void Dispose()
{
}
public void Init(HttpApplication context)
{
context.PostAuthenticateRequest +=
new EventHandler(context_PostAuthenticateRequest);
}
void context_PostAuthenticateRequest(object sender, EventArgs e)
{
CultureInfo currentCulture;
if (Global.gDateFormat.Trim() == "British")
{
currentCulture = new System.Globalization.CultureInfo("en-GB");
}
else
{
currentCulture = new System.Globalization.CultureInfo("en-US");
}
System.Threading.Thread.CurrentThread.CurrentCulture
= currentCulture;
}
}
}
在此之后,我在 web.config 中进行如下配置:
<add name="CultureModule"
type="CwizBankApp.HttpModules.CultureModule,CwizBankApp"/>
目前我的变量是英式格式,但是日期是以美式格式执行的。
我的问题是,我是否以正确的方式进行操作,或者仍然缺少某些东西。
【问题讨论】:
标签: c# asp.net cultureinfo