spark view precompile
来源:互联网 发布:千千静听软件 编辑:程序博客网 时间:2024/05/02 04:51
只要是看E文来的,不管是否加入了整理编排,统统算translation...
原文:http://sparkviewengine.com/documentation/precompiling 不仅限于此文
view descriptors and a SparkViewEngine/
batch descriptor and a SparkViewFactory/
方式一:
Global Application_Start调用以下方法-- 其实不推荐使用在application_start运行如此heavy的代码
public static void PrecompileViews(ControllerBuilder builder) { var controllerFactory = (SparkControllerFactory)builder.GetControllerFactory(); var viewFactory = new SparkViewFactory(controllerFactory.Settings); var batch = new SparkBatchDescriptor(); batch .For<HomeController>() .For<ProductsController>(); viewFactory.Precompile(batch); }
方式二:
var engine = new SparkViewEngine(settings) { ViewFolder = new FileSystemViewFolder(viewsLocation) }; engine.BatchCompilation(targetPath, Global.AllKnownDescriptors());
方法三:这个也是在之前的MVC 多租户中使用到的方式:Precompiling bin-deployable assembly with installutil and with a post-build step
这可能是最酷的方式了,尤其是你开发的web app要部署到一个medium信任共享的环境中,动态产生view dll会存在问题。
我们看一下,如果在web.config中有这个Trust level="Medium",如果web app尝试在运行时编译view,app会抛出exception",接下来我们看看应该怎么做:
1。在toolbox中添加spark.mvc.... precompileInstaller
(If it's not in the toolbox you may need to right-click one of the categories, say "Choose Items...", and Browse... to locate the assembly that contains the tool you want.)
2。在项目中添加installer class,会产生一个设计页面,把precompilerInstaller拖放上去。
3。选中precompileInstaller1,如果愿意,可以在属性中设置target assembly的文件名,默认是assembly+.view//在属性page的events中双击describeBatch。然后添加实现:
private void precompileInstaller1_DescribeBatch(object sender, DescribeBatchEventArgs e) { e.Batch .For<HomeController>() .For<HomeController>().Layout("Ajax").Include("_Notification") .For<AccountController>(); }
4。第4件事也是最后一件事情,在项目的post build event commandline中输入下面的命令
%systemroot%\Microsoft.NET\Framework\v2.0.50727\installutil "$(TargetPath)"
note:请注意修改.net framework的版本
- spark view precompile
- precompile
- C++ - Precompile header file
- Precompile Prefix Header
- View RDD contents in Python Spark
- fatal error C1083(precompile head)
- Xcode Precompile Prefix Header浅析
- Xcode Precompile Prefix Header简析
- Xcode Precompile Prefix Header浅析
- Xcode Precompile Prefix Header浅析
- UE4 iOS Metal precompile shaders
- Xcode Precompile Prefix Header浅析
- Xcode Precompile Prefix Header浅析
- Xcode6 找回消失的 Precompile Prefix Header
- Xcode6添加pch(Precompile Prefix Header)文件
- spark
- spark
- Spark
- Ubuntu12.04下安装JDK
- 3行程序搞定SVM分类-用JAVA程序调用LibSVM API 最简单的示例
- 精 挑 细 选
- Android开发之AlertDialog对话框内gallery的应用案例
- word显示在网页上
- spark view precompile
- error: initializing argument 2 of 'void (* signal(int, void (*)(int)))(int)'
- redis.conf配置文件中文版
- 介绍学习嵌入式开发
- 对tableView的学习情况
- USACO_1.3_barn1
- Ubuntu12.04下安装eclipse
- Web前端开发技术
- Ubuntu下配置Intellij的Android开发环境