简体   繁体   中英

Configuration and Views

I've been developing an application using asp.net MVC, and I have some configurations that influences in process of render a view. For example, a user can choose (in an configuration of system) if a field should appear for a management of records in an area of the system. So, I have an class called AppConfiguration has some properties to represent this configurations.

I guess I need to cache an object of AppConfiguration, and make a ViewModel base class and inherits from my viewmodel, for example:

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

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

and make typed views using "DocumentViewModel" to check the properties if this kind of document is able to render or not ? is it works ? Or is there any other better way to do something like this ?

Thanks all and sorry for my english!

Cheers

我建议您为视图模型编写一个关联的元数据提供程序 ,然后在MVC 2中使用默认的模板视图

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM