Silvester 发表于 2013-1-3 17:29:33

.NET MVC 实现动态换版

<div id="cnblogs_post_body">         .NET 开发项目非常的方便,但是动态换版功能,需要自己去实现,因为项目需要用到,快速换不同的版,对于.Net里面 UrlRewrite + Nvelocity 实现的MVC,换版,非常简单。只在此谈NET MVC 2.0 - 3.0(2.0-3.0 虽然模板引擎有所区别,但是方法同样适用) 实现动态换版功能.
关于动态换版,.net mvc 实现的方式非常多,一下为第一个例子
首先我们来看看我们需要首先的目录:
http://pic002.cnblogs.com/images/2012/329473/2012091518260684.png

如何实现 换版我们需要查看的是MVC RazorViewEngine 可一看到一下受保护的方法
我们不需要实现一个模板引擎 只是改一下路径就行
<div class="cnblogs_code"> 1// 摘要: 2         //   Creates a partial view using the specified controller context and partial 3         //   path. 4         // 5         // 参数: 6         //   controllerContext: 7         //   The controller context. 8         // 9         //   partialPath:10         //   The path to the partial view.11         //12         // 返回结果:13         //   The partial view.14         protected override IView CreatePartialView(ControllerContext controllerContext, string partialPath);15         //16         // 摘要:17         //   Creates a view by using the specified controller context and the paths of18         //   the view and master view.19         //20         // 参数:21         //   controllerContext:22         //   The controller context.23         //24         //   viewPath:25         //   The path to the view.26         //27         //   masterPath:28         //   The path to the master view.29         //30         // 返回结果:31         //   The view.32         protected override IView CreateView(ControllerContext controllerContext, string viewPath, string masterPath);
页: [1]
查看完整版本: .NET MVC 实现动态换版