给定一个域对象:
class BirthdayDomain
{
public DateTime Birthday { get; set; }
public decimal BirthdayPresent { get; set; }
}
我有两个选项可以将它传递给强类型视图:
1.
class BirthdayView
{
public DateTime Birthday { get; set; }
public decimal BirthdayPresent { get; set; }
}
并且在视图中
<%: Model.Birthday.ToString("d"); %>
<%: Model.BirthdayPresent.ToString("C2"); %>
2.
class BirthdayView
{
public string Birthday { get; set; }
public string BirthdayPresent { get; set; }
}
并在控制器中(例如)
BirthdayDomain bd = Repository.GetBirthday(.....)
BirthdayView bv = new BirthdayView()
{
Birthday = bd.Birthday.ToString("d");
BirthdayPresent = bd.BirthdayPresent.ToString("C2");
}
并在视图中只输出字符串。
我的问题是:如果我想支持用户(浏览器?)当前的语言环境设置,以便日期和货币以您期望的方式显示,那么最好的地方是哪里?可以在视图或控制器中完成吗?处理此问题的普遍接受的技术是什么?