六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 161|回复: 0

.NET MVC 实现动态换版

[复制链接]

升级  64%

8

主题

8

主题

8

主题

童生

Rank: 1

积分
32
 楼主| 发表于 2012-12-19 21:03:36 | 显示全部楼层 |阅读模式
<div id="cnblogs_post_body">         .NET 开发项目非常的方便,但是动态换版功能,需要自己去实现,因为项目需要用到,快速换不同的版,对于.Net里面 UrlRewrite + Nvelocity 实现的MVC,换版,非常简单。只在此谈NET MVC 2.0 - 3.0(2.0-3.0 虽然模板引擎有所区别,但是方法同样适用) 实现动态换版功能.
关于动态换版,.net mvc 实现的方式非常多,一下为第一个例子
首先我们来看看我们需要首先的目录:


如何实现 换版我们需要查看的是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);
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表