是否可以使用MVC项目制作单独的DLL? [英] Is it possible to make separate dlls with MVC project?

查看:206
本文介绍了是否可以使用MVC项目制作单独的DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个在Asp.net MVC5开发的大型项目。我们的模型和业务逻辑在单独的类库中定义。现在我们需要在现有的项目中添加另一个模块,但是我们需要一个单独的dll。



此模块还共享最多的javascripts,css文件和其他文件。这就是我们不想分开MVC项目的原因。



有没有为什么我们可以为模块创建单独的dll。所以我们不想部署或触摸其他dll。

解决方案

从您的描述中,您说项目共享CSS和JS文件。这使我相信你在谈论一个单独的MVC网站(可能是较大的公司网站的一部分)。这可以使用区域最简单。如果您不熟悉区域,请阅读以下内容: https://msdn.microsoft.com/en-us/library/ee671793(VS.100).aspx



当然,使用Areas将需要你部署整个网站,每当其中一个地区发生变化时,您已经提到要避免这样做。



如果您不想使用区域,而而是想在同一个解决方案中创建另一个MVC项目,你也可以轻松地做到这一点。您可以右键单击解决方案,添加新项目> ASP.NET Web应用程序> MVC添加项目。要在这两个MVC项目之间共享JS和CSS文件,您将必须创建一个新的解决方案文件夹(右键单击解决方案>添加新的解决方案文件夹),并将资源文件移动到该文件夹​​。在您的解决方案中的每个MVC项目中,您将添加现有项目并选择这些js / css资源文件。这样,如果您更改css文件,它将被反映在这两个项目中。



有关更多信息,请阅读以下内容:



如何分享一个解决方案中的多个项目之间的脚本?


We have a big project developed in Asp.net MVC5. Our models and business logic are defined in separate class libraries. Now we need to add another module to an existing project but we want a separate dll.

This module also shares the most javascripts, css files and other files. That is the reason we don't want to separate MVC project.

Is there any why we can create separate dll for module basis. so we don't want deploy or touch other dlls.

解决方案

From your description, you say that the projects share CSS and JS files. This leads me to believe you are talking about a separate MVC website (possibly part of the larger corporate website). This can be easiest with the use of Areas. If you are not familiar with Areas, please read the following: https://msdn.microsoft.com/en-us/library/ee671793(VS.100).aspx

Of course using Areas will require you to deploy the whole site everytime one of the areas change, and you have mentioned that you want to avoid doing so.

If you don't want to use areas, and instead want to create another MVC project in the same solution, you can do that easily too. You can right click on the solution, add new project > ASP.NET web application > MVC to add the project. To share JS and CSS files between these two MVC projects, you will have to create a new solution folder (right click solution > Add new solution folder), and move your resource files to that folder. Inside each MVC project in your solution, you will add existing items and select those js/css resource files. This way if you change the css file, it will be reflected in both the projects.

For more information, read the following:

How do you share scripts among multiple projects in one solution?

这篇关于是否可以使用MVC项目制作单独的DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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