【问题标题】:Configuration and Views配置和视图
【发布时间】:2023-03-09 01:20:01
【问题描述】:

我一直在使用 asp.net MVC 开发应用程序,并且我有一些配置会影响渲染视图的过程。例如,用户可以选择(在系统配置中)是否应出现字段以管理系统区域中的记录。所以,我有一个名为 AppConfiguration 的类,它有一些属性来表示这种配置。

我想我需要缓存一个AppConfiguration的对象,并创建一个ViewModel基类并从我的viewmodel继承,例如:

public class BaseViewModel {
   public AppConfiguration Config { get; set; }
}

public class DocumentViewModel : BaseViewModel {
   public Document Document { get; set; }
}

并使用“DocumentViewModel”创建类型化视图以检查此类文档是否能够呈现的属性?它有效吗?或者有没有其他更好的方法来做这样的事情?

谢谢大家,对不起我的英语!

干杯

【问题讨论】:

  • 配置数据是来自DB还是来自web.config?
  • 它来自数据库... (by Nhibernate)

标签: asp.net asp.net-mvc configuration viewmodel web-config


【解决方案1】:

我建议您为您的视图模型编写一个关联的 metadata provider,然后在 MVC 2 中使用 default templated views

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-18
    • 2019-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多