从类库加载部分内容
有没有办法从类库加载部分视图?
我想从几个网站中提取公共部分,使它们更易于维护。
目前,我使用(例如)
<%Html.RenderPartial("~/Views/Search/_searchBlock.ascx", ViewData);%>
这是基于文件的来渲染我的部分,但是在创建类库时,会编译视图。 有没有办法加载在此库中编译的库?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为做到这一点的唯一方法是使用 嵌入式资源 和自定义视图引擎。 将反射器(或下载 MVC 源)指向 System.Web.Mvc.Html.RenderPartialExtensions
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
请参阅 Phil Haacks 新帖子了解替代想法
See Phil Haacks new post for an alternative idea