Manish
Manish

Reputation: 1796

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

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)

Upvotes: 41

Views: 96580

Answers (12)

Brandon Dekker
Brandon Dekker

Reputation: 431

I had this issue and tried all of the same things to try to resolve it none of the answers above fixed this. I ended up manually copying the dll file from another project. Put it in the project/bin folder. Several of my extensions had this issue, I'm not sure what caused it. File added to the /bin folder

Upvotes: 0

user3638471
user3638471

Reputation:

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

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

Upvotes: 19

Lester
Lester

Reputation: 1

After adding the correct version of MVC, the reference to Microsoft Web Helper is added but not of System.Web.Helper. Add this manually to your references.

Upvotes: 0

Rudrani Angira
Rudrani Angira

Reputation: 986

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.

Upvotes: 6

Dave
Dave

Reputation: 8471

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.

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

enter image description here

Upvotes: 8

Xu Z.
Xu Z.

Reputation: 11

maybe something wrong with your Web.config file. Open the file and find the <runtime></runtime> tag. modify the version of MVC. For example, 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>

Upvotes: 1

Brian Rice
Brian Rice

Reputation: 3257

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.

Upvotes: 2

SCBuergel
SCBuergel

Reputation: 1653

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.

Upvotes: 2

Geovani Martinez
Geovani Martinez

Reputation: 2153

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.

Upvotes: 16

mab
mab

Reputation: 11

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.

Upvotes: 1

Graham Laight
Graham Laight

Reputation: 4850

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

Upvotes: 25

Arvind Vishwakarma
Arvind Vishwakarma

Reputation: 563

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

Upvotes: 25

Related Questions