ASP.NET MVC 中单独程序集中的视图

编程入门 行业动态 更新时间:2024-10-26 01:26:08
本文介绍了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 时遇到的问题相同.我发现了这个 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 中单独程序集中的视图

本文发布于:2023-11-09 10:11:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1572098.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   程序   ASP   NET   MVC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!