C# 我可以在 .net 4 中部署我的 ASP.NET MVC 4 应用程序吗

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9548283/
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-08-09 07:50:31  来源:igfitidea点击:

Can I deploy my ASP.NET MVC 4 application in .net 4

c#.nethostingasp.net-mvc-4

提问by user1240424

I want to know about a thing that IS ASP.NET MVC 4 application can be run on .NET 4 server.

我想知道 ASP.NET MVC 4 应用程序可以在 .NET 4 服务器上运行的事情。

I am trying to deploy my MVC4 application and I am got the error that.

我正在尝试部署我的 MVC4 应用程序,但出现错误。

500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.

500内部服务器错误。
您要查找的资源有问题,无法显示。

I target the .net 4 framework but I am still having this error. I am not sure what happen to server. I am trying to look on other post but I did not find any post who can clearify that MVC 4 can run on .net server.

我的目标是 .net 4 框架,但我仍然遇到此错误。我不确定服务器会发生什么。我正在尝试查看其他帖子,但我没有找到任何可以明确 MVC 4 可以在 .net 服务器上运行的帖子。

回答by Dan Sorensen

Yes. ASP.Net MVC 4 will run on ASP.Net 4 and ASP.Net 4.5. I am running a site on ASP.Net 4, and it is also confirmed in this blog post by Scott Gu. This assumes that you are not targeting any new 4.5 features in your application.

是的。ASP.Net MVC 4 将在 ASP.Net 4 和 ASP.Net 4.5 上运行。我正在 ASP.Net 4 上运行一个站点,Scott Gu这篇博文中也证实了这一点。这假设您的应用程序中没有针对任何新的 4.5 功能。

Be sure that you are copying the required MVC 4 .dll files in your bin folder if the server does not already have them installed. This post by Phil Haackexplains how to bin deploy version 3. Hanselman has a similar article. You will need to check the version 4 release notesfor the current .dlls required.

如果服务器尚未安装所需的 MVC 4 .dll 文件,请确保将所需的 MVC 4 .dll 文件复制到 bin 文件夹中。Phil Haack 的这篇文章解释了如何 bin 部署版本3。Hanselman 有一篇类似的文章。您需要查看当前所需的 .dll的第 4 版发行说明

We may be able to provide a more specific answer if you can provide some additional details, and let us know what version of IIS and Visual Studio you are running.

如果您能提供一些其他详细信息,我们可能会提供更具体的答案,并让我们知道您正在运行的 IIS 和 Visual Studio 版本。

回答by azraelrabbit

  1. Right click your mvc4/webapi project ,choose the "Add Library Package Reference..." item, checked the "ASP.NET MVC" checkbox .
  2. Install DotNet Framework 4 Client Profile on your server.Because of the reference item "System.Net.Http" target framework is .net4 client profile.
  3. Publish your mvc4 project to your server
  4. enjoy......:)_
  1. 右键单击您的 mvc4/webapi 项目,选择“添加库包引用...”项,选中“ASP.NET MVC”复选框。
  2. 在您的服务器上安装 DotNet Framework 4 Client Profile。因为参考项“System.Net.Http”目标框架是 .net4 客户端配置文件。
  3. 将您的 mvc4 项目发布到您的服务器
  4. 请享用......:)_

回答by gdoron is supporting Monica

Razor 2 is part of the next wave of the WebPages/MVC framework so it will require MVC4. There's nothing stopping you from using our Open-Source code to wedge Razor 2 in to MVC3, but it isn't a supported scenario.

Remember that MVC 4 works on .NET 4.0 and does NOT require .NET 4.5!

Razor 2 是下一波 WebPages/MVC 框架的一部分,因此它将需要 MVC4。没有什么能阻止您使用我们的开源代码将 Razor 2 融入 MVC3,但这不是受支持的场景。

请记住,MVC 4 适用于 .NET 4.0,不需要 .NET 4.5!

ASP.net mvc programmer blog

ASP.net mvc 程序员博客