ASP.NET MVC 中单独程序集中的视图 [英] Views in separate assemblies in ASP.NET MVC

查看:33
本文介绍了ASP.NET MVC 中单独程序集中的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个 Web 应用程序,我希望能够在其中插入单独的程序集.我将 MVC preview 4 与 Unity 结合使用进行依赖注入,我用它来从我的插件程序集创建控制器.我使用 WebForms(默认 aspx)作为我的视图引擎.

I'm trying to create a webapplication where I want to be able to plug-in separate assemblies. I'm using MVC preview 4 combined with Unity for dependency injection, which I use to create the controllers from my plugin assemblies. I'm using WebForms (default aspx) as my view engine.

如果我想使用视图,我卡在核心项目中定义的那些,因为ASPX部分的动态编译.我正在寻找一种将 ASPX 文件包含在不同程序集中的正确方法,而无需完成整个部署步骤.我错过了一些明显的东西吗?还是应该求助于以编程方式创建视图?

If I want to use a view, I'm stuck on the ones that are defined in the core project, because of the dynamic compiling of the ASPX part. I'm looking for a proper way to enclose ASPX files in a different assembly, without having to go through the whole deployment step. Am I missing something obvious? Or should I resort to creating my views programmatically?

更新:我更改了已接受的答案.尽管 Dale 的回答非常彻底,但我还是选择了不同的虚拟路径提供者的解决方案.它就像一个魅力,我认为总共只需要大约 20 行代码.

Update: I changed the accepted answer. Even though Dale's answer is very thorough, I went for the solution with a different virtual path provider. It works like a charm, and takes only about 20 lines in code altogether I think.

推荐答案

本质上,这与人们在使用 WebForms 并试图将他们的 UserControl ASCX 文件编译为 DLL 时遇到的问题相同.我发现了这个 http://www.codeproject.com/KB/aspnet/ASP2UserControlLibrary.aspx 这也可能对你有用.

Essentially this is the same issue as people had with WebForms and trying to compile their UserControl ASCX files into a DLL. I found this http://www.codeproject.com/KB/aspnet/ASP2UserControlLibrary.aspx that might work for you too.

这篇关于ASP.NET MVC 中单独程序集中的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆