我一直在使用 asp.net MVC,但仍然不太擅长。 然而,我开始想知道如何创建可以“插入”或以最小的复杂性安装到现有 ASP.net MVC 站点中的应用程序。
例如,在 ASP.net Web 表单中,我开发了一种博客应用程序。 为了安装这个应用程序,我只需要将 dll 放入 Bin 文件夹中,添加一些 web.config 行,然后根据需要向 aspx 页面添加控件。 无需进行其他更改。
现在我正在使用 MVC,并且遇到了部分视图,它们似乎以某种方式取代了 Webform 用户控件。 但是,似乎您仍然需要从控制器传递部分视图的数据,并且该数据的级别比页面更高。 我必须修改控制器代码才能安装应用程序。
我很确定我正在以错误的心态思考这个问题。 有没有一种方法可以为 ASP.NET MVC 创建可以轻松插入现有网站的应用程序?
I've been working with asp.net MVC and am still not very good at it. However, I have started wondering how would I go about creating applications that can be "plugged" or installed into an existing ASP.net MVC site with minimal complexity.
For example, in ASP.net web forms I developed a sort of Blogging app. In order to install this app I just need to drop a dll into the Bin folder, add a few web.config lines and then add controls to the aspx pages as needed. No other change needs to be made.
Now I'm working with MVC and I've come across partial views which seem to replace webform usercontrols in some way. However, it seems you still need to pass the partial view's data from the controller and that is at a higher level than the page. I'd have to modify controller code to install an app.
I'm pretty sure I am thinking about this with the wrong mindset. Is there a way to create applications for asp.net mvc that can be easily plugged into an existing web site?
发布评论
评论(2)
已在 ASP.NET MVC 的插件架构中回答
另请参阅:
ASP.NET MVC 插件
插件混合:ASP.NET WebForms 与 ASP.MVC 和 ASP.NET 动态数据并排
ASP.NET MVC - 如何实现插件架构
Already answered in Plug-in architecture for ASP.NET MVC
See Also:
ASP.NET MVC Plugins
Plug-In Hybrids: ASP.NET WebForms and ASP.MVC and ASP.NET Dynamic Data Side By Side
ASP.NET MVC - how to implement the plugin architecture
我已经做了很多这样的工作,我几乎获得了从这里开始所需的所有信息:
http://www.codeproject.com/KB/cs/pluginsincsharp.aspx
我使用插件的最大项目是一个音频处理应用程序。
总体思路是:
在单独的、可分发的、签名的 DLL 中为所需的每种插件类型创建一个接口。 下面是一个示例接口:
然后在您的插件 dll 中,您使用该接口实现一个类:
然后使用反射加载 DLL:
然后砰的一声,您就拥有了您的插件!
I have done quite a lot of work like this and I got almost all of the information I neeed to start from here:
http://www.codeproject.com/KB/cs/pluginsincsharp.aspx
My largest project using plugins was an audio processing app.
The general Idea is:
You create an interface for each of the plugin types you need in a separate, distributable, signed DLL. Here is an example interface:
Then in your plugin dll, you implement a class with the interface:
Then you load the DLL using reflection:
And BAM you have your plugins!