在 MVC 中创建单独的模块,就像在 DotNetNuke 中一样

发布于 2024-07-26 11:14:03 字数 192 浏览 3 评论 0原文

我刚刚开始关注 ASP.Net MVC,但在我们当前正在开发的网站上,我们使用 DotNetNuke,而且我实际上很喜欢创建新“模块”并将它们插入到您的网站的方式轻松(如果模块编码正确的话)。

使用 Asp.Net MVC 模式可以实现这一点吗? 您让一位同事创建了一个新的 .dll,设计人员只需将其插入到网站中,而无需太多或任何代码隐藏交互?

I've newly started to open my eyes for ASP.Net MVC, but on the site we are currently working on we use DotNetNuke, and I actually like the way you can create new "Modules" and just plug them in to your site with ease (If the module is coded right that is).

Can you achieve this when using the Asp.Net MVC pattern? That you have a co-worker create a new .dll that the designer just can plug into the site without much or any code-behind interaction?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

愛上了 2024-08-02 11:14:03

为什么不?

这与整个过程中使用的“Provider 模式”非常相似.net 框架。 对于.net框架中的模块,它可以动态加载不同的Provider,而无需接触源代码,所有这些都必须在xml配置文件中完成。

实际上,您创建一个 ModuleProvider 基类,所有模块都将从该基类继承。 在主控制器中,它加载不同的 ModuleProvider 并让它们完成其余的工作。

要解释什么是提供者模式以及如何设计将是一个很长的段落。 请阅读上面的链接并研究框架中使用的那些提供程序。

Why not?

This would be very much similar to the "Provider pattern" used across the entire .net framework. For modules in .net framework, it can dynamically load different Provider without touching the source code, all has to be done in the xml config file.

In practice, you create a ModuleProvider base class, which all modules are going to inherit from this. In the master controller, it loads different ModuleProviders and let them do the rest.

It would be a long passage to explain what the provider pattern and how's the design is to be. Please read the link above and study those provider used in the framework.

妄想挽回 2024-08-02 11:14:03

Andrew Nurse(DNN 高级开发人员 Charles Nurse 的儿子)已经开始在 ASP.NET MVC 中创建一个类似于 DNN 的可插入功能的基本框架,称为 Maverick,您可能会感兴趣。

Andrew Nurse (son of DNN's senior developer, Charles Nurse) has begun a basic framework for pluggable DNN-like functionality in ASP.NET MVC, called Maverick, which might be interesting to you.

千笙结 2024-08-02 11:14:03

你会错过一些重要的东西。 可以在 MVC 的单独 dll 中包含可重用代码,但由于控件(也称为模块)的使用受到限制,因此很难实现有用的实现。 老派 ASP.NET 对于此类应用程序来说要好得多。

事件

如果您有一个控件,您经常需要它来接收事件或发送事件。 这只能在 ASP.NET Web 表单中实现。

属性

在控件的容器上,您经常需要设置公共属性。 这也是 ASP.NET Webforms。

我提到过 ViewState 吗? 我应该...

我不想让您远离 ASP.NET MVC。 它是一个非常好的框架,但我在 DotNetNuke 之类的应用程序中没有看到它。

You will be missing some essential things. Its possible to have reusable code in a separate dll for MVC, but because the usage of controlls (aka modules ) is limited it will be difficult to have a usefull implementation. Oldschool ASP.NET is so much nicer for this kind of applications.

Events

If you have a control you often need it to receive events or send events. Thats only possible in ASP.NET webforms.

Properties

On the container of a control you often have to set public properties. Thats also ASP.NET Webforms.

Did I mention ViewState? I should...

I dont want to take you away from ASP.NET MVC. Its a realy good framework, but I dont see it in a DotNetNuke like application.

許願樹丅啲祈禱 2024-08-02 11:14:03

查看此博客条目 http://blogs.msdn.com/hammett/

演示如何在 DLL 中嵌入 .aspx 和 .ascx 页面,只需将 DLL 拖放到主应用程序 bin 目录中即可添加功能。 路线和导航。 它使用 MEF,但您只需做一点工作就可以做到这一点。

Check out this blog entry http://blogs.msdn.com/hammett/.

Shows how to embed .aspx and .ascx pages in the DLL by just dropping the DLL in the main apps bin directory, you add the functionality. routing, and navigation. It uses MEF, but you could do it without with a little work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文