如何在多个应用程序中重用MVC3控制器/视图?

时间:2022-10-24 05:33:03

I am rewriting some old ASP applications that were not well structured and trying to learn .NET and MVC3 in the process. There are two main applications, one of which reuses code from the other and is really just a very limited version of the other one. One provided "power" users with reports on any person in the database. The other one provided a report only on the individual requesting the report. These are on separate servers, the more limited one in a DMZ and the more powerful one behind a second firewall.

我正在重写一些结构不好的旧ASP应用程序,并尝试在此过程中学习.NET和MVC3。有两个主要的应用程序,其中一个重用另一个的代码,实际上只是另一个的非常有限的版本。一个向“权力”用户提供有关数据库中任何人的报告。另一个仅针对请求报告的个人提供了报告。这些服务器位于不同的服务器上,DMZ中的服务器数量较多,而第二个防火墙服务器数量较多。

My question is, since the actual report is the same for both, just parameterized for the more powerful one to allow it to be run on any user, I do NOT want to copy-and-paste reuse the report generation from one side to the other. I would like to make some kind of reusable library of the controller and views/partials that would provide the same information, and allow me to maintain it all in one place.

我的问题是,由于实际报告对于两者都是相同的,只是为更强大的报告参数化以允许它在任何用户上运行,我不希望将报告生成从一侧复制并粘贴到其他。我想制作某种可重复使用的控制器库和视图/局部文件,它们可以提供相同的信息,并允许我将它们保存在一个地方。

Is this possible with MVC3? Or is there a better approach? I searched here a bit but didn't find anything on this, but maybe I just didn't use the right terms.

这可能与MVC3有关吗?还是有更好的方法?我在这里搜索了一下但没有找到任何关于此的内容,但也许我没有使用正确的术语。

I'm on VS2010, C#, MVC3 with Razor.

我在VS2010,C#,MVC3和Razor。

Thanks in advance.

提前致谢。

1 个解决方案

#1


1  

MVC Contrib project has portable areas.

MVC Contrib项目有便携式区域。

http://mvccontrib.codeplex.com/documentation

http://mvccontrib.codeplex.com/documentation

#1


1  

MVC Contrib project has portable areas.

MVC Contrib项目有便携式区域。

http://mvccontrib.codeplex.com/documentation

http://mvccontrib.codeplex.com/documentation