如何在mvc中创建可重用的模块? [英] how to create reusable module in mvc ?

查看:79
本文介绍了如何在mvc中创建可重用的模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在mvc中创建可重用的组件



登录模块登录,更改3层架构密码

in mvc



我希望在其他项目中集成的模块

基本上我希望这个模型作为用户控制





有什么办法



我在想创造nuget包是不是正确的方式

我将添加此套餐

是否有效?



https://www.nuget.org/packages/CreateNewNuGetPackageFromProjectAfterEachBuild/



或者还有其他方式

I want to create reusable component in mvc

Login module with login ,change password in 3 tier architecture
In mvc

That module I want to integrate in other projects
Basically I want this model as user control


Is there any way

I was thinking create nuget package is it right way
This package I will add
Will it work??

https://www.nuget.org/packages/CreateNewNuGetPackageFromProjectAfterEachBuild/

Or there is other way

推荐答案

有两种主要方法:

)某种插件系统。

因为你可以在一个assambly中编译很多东西,你可以简单地做到这一点,然后让你的登录dll。但是有一些重要的事情需要解决。所以你最好找一个现成的解决方案。 MVC中有一个称为area的概念。这是一篇很好的文章: ASP.NET MVC 4中的区域 [ ^ ]。您可以进一步创建和使用便携式区域。我想这将非常接近您所寻找的内容: http://lostechies.com/erichexter/2009/11/02/asp-net-mvc-portable-areas-part-2/ [ ^ ]。它有它的缺点,它被认为是过时的(多年来不支持MvcContrib),但这是一种有效的编码方法。它仍适用于成熟项目。

请参阅disavantages: http:// stackoverflow。 com / questions / 17140271 / portable-area-defects [ ^ ]



1.5)我没有测试过这种方法,但看起来很有希望。您可以使用WebActivator获得相同的结果。请参阅: http://kennytordeur.blogspot.hu/2012/12 /aspnet-mvc-reuse-areas-from-external.html [ ^ ]



2)使用nuget。通过这种方法,您不会创建可重用的组件,而是为功能创建可重用的模板。它不利于您的应用程序的任何插件架构。
There are two major approaches:
1) Some sort of plugin system.
As you can compile much anything in an assambly, you could simply do that, and have your login dll. But there are severeal thing to solve. So you better look for a ready-made solution. There is a concept in MVC called area. This is a good article about it: Areas in ASP.NET MVC 4[^] . You can go further creating and consuming portable areas. I suppose this will be really near to what you are looking for: http://lostechies.com/erichexter/2009/11/02/asp-net-mvc-portable-areas-part-2/[^]. It has its drawbacks, it is considered outdated (MvcContrib is not supported for some years), but this is a working coded approach. Still it is suitable for mature projects only.
See disavantages: http://stackoverflow.com/questions/17140271/portable-area-disadvantages[^]

1.5) I haven't tested this approach, but looks promising. You can use WebActivator to achive much the same results. See this: http://kennytordeur.blogspot.hu/2012/12/aspnet-mvc-reuse-areas-from-external.html[^]

2) Using nuget. By this approach you don't create reusable component, you create reusable template for a functionality. It does not facilitate any plugin schema for your application.


这篇关于如何在mvc中创建可重用的模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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