asp.net-mvc 我是否需要在 Web 服务器上安装 MVC 3/4 才能运行 mvc 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10441568/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 01:55:22  来源:igfitidea点击:

Do I need to install MVC 3/4 on web server to run mvc application

asp.net-mvcasp.net-mvc-3

提问by Nil Pun

I've a MVC 4 application and runs well on my DEV Machine where I installed MVC 4 extension for VS 2010.

我有一个 MVC 4 应用程序并且在我的 DEV 机器上运行良好,我在其中安装了 VS 2010 的 MVC 4 扩展。

When deploying to the web server with IIS 7, do I need to install MVC 4 or should the dll included on my project is sufficient?

使用 IIS 7 部署到 Web 服务器时,我需要安装 MVC 4 还是我的项目中包含的 dll 就足够了?

The reason I'm asking is we need to provide the requirement to infrastructure team.

我问的原因是我们需要向基础架构团队提供需求。

Thanks.

谢谢。

回答by Shyju

You can run an MVC application without installing MVC on your server. There is something called deployable dependencyin Visual studio. That will publish your MVC DLLs in your bin folder when you publish it.

您无需在服务器上安装 MVC 即可运行 MVC 应用程序。Visual Studio 中有一种叫做可部署依赖的东西。当您发布它时,这将在您的 bin 文件夹中发布您的 MVC DLL。

from the msdnpage,

msdn页面,

This will add assemblies (DLL files) to a Web site project or Web application project. When you deploy your Web site or application, the files are included in the deployed project. This is useful if applications or technologies that your project depends on are not already installed on the server that will host your Web project. For example, you can use this feature to deploy an ASP.NET MVC 3 Web application to a server that does not have ASP.NET MVC 3 installed.

这会将程序集(DLL 文件)添加到网站项目或 Web 应用程序项目。当您部署网站或应用程序时,这些文件将包含在已部署的项目中。如果您的项目所依赖的应用程序或技术尚未安装在将承载您的 Web 项目的服务器上,这将非常有用。例如,您可以使用此功能将 ASP.NET MVC 3 Web 应用程序部署到未安装 ASP.NET MVC 3 的服务器。

Right Click on Project and Select Add Deployable Dependency from the context menu

右键单击项目并从上下文菜单中选择添加可部署依赖项

enter image description here

在此处输入图片说明

Select what all DLLs you want to be published

选择要发布的所有 DLL

enter image description here

在此处输入图片说明

After clicking OK, You will see a new folder called _bin_deployableAssemblies. You can do normal Publishing procedure now and you will have the dlls in the bin folder of the publish output.

单击确定后,您将看到一个名为 _bin_deployableAssemblies 的新文件夹。您现在可以执行正常的发布程序,您将在发布输出的 bin 文件夹中拥有 dll。

enter image description here

在此处输入图片说明

Check this post for more details http://haacked.com/archive/2011/05/25/bin-deploying-asp-net-mvc-3.aspx

查看这篇文章了解更多详情http://haacked.com/archive/2011/05/25/bin-deploying-asp-net-mvc-3.aspx

You should have Visual Studio 2010 SP1. Otherwise it will not be shown in the context menu when you right click on the project to be published.

你应该有 Visual Studio 2010 SP1。否则,当您右键单击要发布的项目时,它不会显示在上下文菜单中。

EDIT :As of MVC4, all necessary assemblies to run an MVC application are automatically added to the bin directory, and any MVC4 application is bin-deployable (means you can run it in a server without explicitly installing MVC) . For this reason, the Include Deployable Assemblies dialog has been removed from Visual Studio 2012

编辑:从 MVC4 开始,运行 MVC 应用程序所需的所有程序集都会自动添加到 bin 目录中,并且任何 MVC4 应用程序都是 bin-deployable(意味着您可以在服务器中运行它而无需显式安装 MVC)。因此,包含可部署程序集对话框已从 Visual Studio 2012 中删除

回答by Bogdan Gavril MSFT

You no longer have the option to "Add deployable dependencies" in Visual Studio 2012. So you'll have to do it manually, by bin deploying all the MVC assemblies:

在 Visual Studio 2012 中,您不再可以选择“添加可部署的依赖项”。因此,您必须手动完成,通过 bin 部署所有 MVC 程序集:

Microsoft.Web.Infrastructure
System.Web.Helpers
System.Web.Mvc
System.Web.Razor
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor

A step by step guide is found here.

可在此处找到分步指南。

回答by AvkashChauhan

When u create a MVCx specific project in Visual Studio you will see lots of MVC.* references are added to your project and by default all of these reference property "Copy Local" is set as "True" means these references will be part of your final solution whenever you will deploy to. You can also verify that these MVC specific references are also part of your BIN folder.

当您在 Visual Studio 中创建特定于 MVCx 的项目时,您会看到许多 MVC.* 引用添加到您的项目中,并且默认情况下所有这些引用属性“Copy Local”都设置为“True”意味着这些引用将成为您的一部分无论何时部署到最终解决方案。您还可以验证这些特定于 MVC 的引用是否也是您的 BIN 文件夹的一部分。

Finally when you will package this solution and publish to a specific Web Server or to Windows Azure or use WebDeploy, all of these references will be part of your package also. And because these references are shipped in your package so where ever you will deploy the solution, all MVC specific references will be there and because of that you don't need to deploy MVC to those specific servers.

最后,当您将此解决方案打包并发布到特定的 Web 服务器或 Windows Azure 或使用 WebDeploy 时,所有这些引用也将成为您的包的一部分。并且因为这些引用在您的包中提供,所以无论您将解决方案部署到何处,所有 MVC 特定引用都将存在,因此您无需将 MVC 部署到那些特定服务器。

I would also like to add that any time when you add a specific reference to your project in Visual Studio, set its property "Copy Local" to TRUE so that reference will always be part of your final solution, and will save you from trouble in future.

我还想补充一点,当您在 Visual Studio 中添加对项目的特定引用时,请将其属性“Copy Local”设置为 TRUE,以便该引用将始终是您最终解决方案的一部分,并且可以避免您在未来。

回答by Josh Mein

You only need to have the dlls deployed into the bin of your project. For an example of how to prepare your web site for release check out the following blog post:

您只需要将 dll 部署到项目的 bin 中。有关如何准备发布网站的示例,请查看以下博客文章:

running-an-asp-net-mvc-3-app-on-a-web-server-that-doesn-t-have-asp-net-mvc-3-installed.aspx.

运行-an-asp-net-mvc-3-app-on-a-web-server-that-doesn-t-have-asp-net-mvc-3-installed.aspx