C# 无法加载文件或程序集“System.Web.Helpers,IIS 8 上的错误”

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

Could not load file or assembly 'System.Web.Helpers, error on IIS 8

c#asp.netasp.net-mvc-4iis

提问by Manish

I have a MVC4 web application that works fine on Visual Studio 2012, using the local IIS Express Server. When I publish the application to an IIS 8 web server running on Windows 2012, the initial login page displays correctly. However, using remote debugging, I see that when I check the credentials using the following line:

我有一个 MVC4 Web 应用程序,它使用本地 IIS Express 服务器在 Visual Studio 2012 上运行良好。当我将应用程序发布到在 Windows 2012 上运行的 IIS 8 Web 服务器时,初始登录页面会正确显示。但是,使用远程调试时,我看到当我使用以下行检查凭据时:

if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))

I get the error shown in the figure below: System.Web.Helpers error
(source: usf.edu)

我得到如下图所示的错误:( 来源:usf.eduSystem.Web.Helpers 错误

回答by Arvind Vishwakarma

Solution - Copy reference to local

解决方案 - 将引用复制到本地

  1. Right click on reference System.Web.Helpers and select Properties
  2. Change Copy Local to true.
  3. Build Solution
  1. 右键单击引用 System.Web.Helpers 并选择属性
  2. 将复制本地更改为 true。
  3. 构建解决方案

回答by Graham Laight

Sounds as though MVC has not been installed on the server.

听起来好像服务器上没有安装 MVC。

回答by mab

I had the same problem working with WCF service in IIS 8. Take a look at this solution Deploying ASP.NET, it worked for me.

我在 IIS 8 中使用 WCF 服务时遇到了同样的问题。看看这个解决方案Deploying ASP.NET,它对我有用。

回答by Geovani Martinez

I was able to resolve this by downloading the Microsoft Web Platform Installer, searching for MVC and installing the "ASP.NET MVC3 (Visual Studio 2010 ) Released 4/11/2011" package. Close any Visual Studio instance prior to installing.

我能够通过下载Microsoft Web Platform Installer、搜索 MVC 并安装“ASP.NET MVC3 (Visual Studio 2010) Released 4/11/2011”包来解决此问题。在安装之前关闭任何 Visual Studio 实例。

回答by SCBuergel.eth

I am running VS 2015Preview and could resolve the issue by installing the latest version of MVC via NuGet.

我正在运行 VS 2015Preview,可以通过 NuGet 安装最新版本的 MVC 来解决该问题。

Just in case anyone is still coming across this one.

以防万一有人仍然遇到这个。

回答by Brian Rice

I added "Microsoft ASP.NET Razor" using Manage NuGet Packages.

我使用管理 NuGet 包添加了“Microsoft ASP.NET Razor”。

With Add References, for some reason, I only had System.Web.Helpers 1.0.0 and 2.0.0... but not 3.0.0.

使用添加引用,出于某种原因,我只有 System.Web.Helpers 1.0.0 和 2.0.0...但没有 3.0.0。

回答by Xu Z.

maybe something wrong with your Web.configfile. Open the file and find the <runtime></runtime>tag. modify the version of MVC. For example, MVC 3

您的Web.config文件可能有问题。打开文件并找到<runtime></runtime>标签。修改MVC版本。例如,MVC 3

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>

回答by Xu Z.

The System.Web.Helpers.dllis included in the official Nuget package Microsoft.AspNet.WebPages.

System.Web.Helpers.dll被包括在官方的NuGet包Microsoft.AspNet.WebPages

Install that and the references should be corrected, and the file should be copied to your bin folder.

安装它,引用应该更正,文件应该复制到你的 bin 文件夹。

回答by Rudrani Angira

Just adding to the existing answers as even I ran into the same error and could not find the the reference in assemblies. I will just share what helped me:

只是添加到现有答案中,因为即使我遇到了同样的错误并且在程序集中找不到引用。我将分享对我有帮助的内容:

Open package Manager from Tools->NuGet Package Manager->Package Manager Console and type:

从 Tools->NuGet Package Manager->Package Manager Console 打开包管理器并输入:

PM> Install-Package microsoft-web-helpers

After this System.Web.Helpers will appear under References->Assemblies. From there the 'Copy local' property can be changed to True.

在此之后 System.Web.Helpers 将出现在 References->Assemblies 下。从那里可以将“复制本地”属性更改为 True。

回答by Dave

Make sure it's looking for the correct version of the file. Mine were incorrect, the web.config file was pointing to later versions than what I had in the project.

确保它正在寻找文件的正确版本。我的不正确,web.config 文件指向的版本比我在项目中的版本要高。

In the properties I noted the version was 2.0.0.0 so I made it this version in the web.config file

在属性中我注意到版本是 2.0.0.0 所以我在 web.config 文件中设置了这个版本

enter image description here

在此处输入图片说明