'Could not load file or assembly 'System.Web.Helpers' or one of its dependencies

I also had this problem when creating a new Razor view. The project was looking for a newer version of the System.Web.Helper and System.Web.WebPages dlls. I solved this issue by editing my web.config and changing the newVersion from 3.0.0.0 to 2.0.0.0. You may also be able to remove these entirely from the web.config as I did.

 <dependentAssembly>
    <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="2.0.0.0" />
  </dependentAssembly>

Referenced version of System.Web.Helpers assembly in project may not be matching with version mentioned in web.config file. Follow below mentioned steps.

  1. Check referenced version of System.Web.Helpers.
  2. Check web.config file under root of web application and see if there is entry for System.Web.Helpers and verify its same as that of referenced version.
  3. Check web.config file under "Views" folder of web application and see if there is entry for System.Web.Helpers and verify its same as that of referenced version.

I had this problem. It was caused when I added a Razor view to a Web Forms project. Because of this action, Visual Studio added in .Net Version 5 and made a whole lot of other modifications to the project.

I fixed the problem by going into Solution Explorer > Pending Changes. I observed a whole heap of unusual files listed. I right-clicked on any of the files and went to Source Control > Undo Pending Changes. I selected the unusual files and Undo Changes and after a rebuild it was fixed.

I've seen these extra files get added (for no apparent) reason at other times also. Some whack-a-doodle thing Visual Studio does for reasons not clear to me.