我正在尝试创建一个 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 时遇到的问题相同.我发现了这个 www.codeproject/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 www.codeproject/KB/aspnet/ASP2UserControlLibrary.aspx that might work for you too.
更多推荐
ASP.NET MVC 中单独程序集中的视图
发布评论