How to create an ASP.NET MVC 3 control/component that can be reused by other applications

送分小仙女□ 提交于 2019-12-03 07:40:28

问题


I am required to deliver a component, inlcuding business logic and UI, to be used on a ASP.NET MVC 3 web site that is being developed by other company.

I know my way around ASP.NET WebForms server controls and how to package and distribute them to be reused across projects. I also have experience with MVC approach in general and some ASP.NET MVC experience. I did read over materials recommending use of HTML helpers and similar, but most of this deals with only UI reusability or reusability inside a single ASP.NET MVC project. I did not find any mentions of how to package and distribute such functionality for ASP.NET MVC.

The business logic is major part of this component. It is supposed to be a kind of wizard, which progresses through a lot of steps and which would also work with database using Entity Framework and send an email to the user upon completion.

  • How would I go about creating a control/component that encapsulates complex business logic and also renders its own UI/view output and that would be distributable in form of a standalone assembly? Is this even possible or only to some extend?

  • Would this somehow be doable by wrapping model, view and controller inside an assembly?

  • Or would it be better to approach this just as a complex model? If so, how would it be possible to connect the UI/view and controller to this component by the consumer of the component?

I also did see a couple of vendors out there, such as Telerik, who sell something along the lines of ASP.NET MVC controls/components, so I assume this is somehow possible to do.


回答1:


This article tells how to call controllers from another assemblies.

To reuse only views, you can use RazorGenerator.




回答2:


I recommend you to refer the MVC Control ToolKit Project page of CodePlex

Also see ASP.Net MVC Sprite Project



来源:https://stackoverflow.com/questions/8093389/how-to-create-an-asp-net-mvc-3-control-component-that-can-be-reused-by-other-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!