Could not load file or assembly 'System.Web.He

2020-01-29 06:47发布

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:

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)

11条回答
SAY GOODBYE
2楼-- · 2020-01-29 07:08

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
查看更多
Bombasti
3楼-- · 2020-01-29 07:10

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:

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.

查看更多
聊天终结者
4楼-- · 2020-01-29 07:12

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

查看更多
该账号已被封号
5楼-- · 2020-01-29 07:18

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

Just in case anyone is still coming across this one.

查看更多
甜甜的少女心
6楼-- · 2020-01-29 07:20

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

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

查看更多
登录 后发表回答