[英]Load partial from class library
Is there a way to load partial views from a class library? 有没有办法从类库加载局部视图?
I would like to pull out the common parts from several websites to make them easier to maintain. 我想从几个网站中提取一些共同的部分,以使其易于维护。
Currently I render my partials with (for example) 目前,我使用(例如)渲染我的局部
<%Html.RenderPartial("~/Views/Search/_searchBlock.ascx", ViewData);%>
This is file based, but when creating a class library, the views are compiled. 这是基于文件的,但是在创建类库时,将编译视图。 Is there a way to load libraries that are compiled in this library?
有没有办法加载在此库中编译的库?
The only way i can think to do this would be with embedded resources and a custom viewengine. 我能想到的唯一方法是使用嵌入式资源和自定义视图引擎。 Point reflector (or download the MVC soruce) at System.Web.Mvc.Html.RenderPartialExtensions
在System.Web.Mvc.Html.RenderPartialExtensions上的点反射器(或下载MVC soruce)
参见Phil Haacks的新帖子,了解其他想法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.