Click here to Skip to main content
15,121,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
An existing project was working just fine. Then I had to repair it because of the mvc.dll update microsoft did. After this I updated my nuget packages. Now I'm getting red squiggly lines in my razor files, and reports of an error. My project compiles and runs fine... but the intellisense doesn't work.

Error	49	'System.Web.WebPages.Html.HtmlHelper' does not contain a definition for 'ActionLink' and no extension method 'ActionLink' accepting a first argument of type 'System.Web.WebPages.Html.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)


From what I'm reading, it has to do with the web.config, but I haven't found anything to be a solution. I'm stuck using mvc4, upgrading to mvc5 is not an option.

Everything in the configuration files were auto generated. The bindings were added by vs (I clicked on the error message and it added the bindings for me). I only added the kendo part as per the kendo docs.

Heres my views/web.config:

XML
<?xml version="1.0"?>

<configuration>
  <configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    </sectionGroup>
  </configSections>

  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization"/>
        <add namespace="System.Web.Routing" />
        <add namespace="Kendo.Mvc.UI"/>
      </namespaces>
    </pages>
  </system.web.webPages.razor>

  <appSettings>
    <add key="webpages:Enabled" value="false" />
  </appSettings>

  <system.web>
    <httpHandlers>
      <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
    </httpHandlers>

    <!--
        Enabling request validation in view pages would cause validation to occur
        after the input has already been processed by the controller. By default
        MVC performs request validation before a controller processes the input.
        To change this behavior apply the ValidateInputAttribute to a
        controller or action.
    -->
    <pages
        validateRequest="false"
        pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <controls>
        <add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
      </controls>
    </pages>
  </system.web>

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />

    <handlers>
      <remove name="BlockViewHandler"/>
      <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
    </handlers>
  </system.webServer>
</configuration>



And here is my main web.config:

XML
<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
                        
  <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --><sectionGroup name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection, DotNetOpenAuth.Core">
			<section name="messaging" type="DotNetOpenAuth.Configuration.MessagingElement, DotNetOpenAuth.Core" requirePermission="false" allowLocation="true"/>
			<section name="reporting" type="DotNetOpenAuth.Configuration.ReportingElement, DotNetOpenAuth.Core" requirePermission="false" allowLocation="true"/>
		<section name="openid" type="DotNetOpenAuth.Configuration.OpenIdElement, DotNetOpenAuth.OpenId" requirePermission="false" allowLocation="true"/><section name="oauth" type="DotNetOpenAuth.Configuration.OAuthElement, DotNetOpenAuth.OAuth" requirePermission="false" allowLocation="true"/></sectionGroup><sectionGroup name="elmah">
      <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah"/>
      <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah"/>
      <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah"/>
      <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah"/>
    </sectionGroup></configSections>
  <connectionStrings>
    <!-- snip -->
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0"/>
    <add key="webpages:Enabled" value="false"/>
    <add key="PreserveLoginUrl" value="true"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
  </appSettings>
  
  <!--
    For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.

    The following attributes can be set on the <httpRuntime> tag.
      <system.Web>
        <httpRuntime targetFramework="4.5" />
      </system.Web>
  -->
  <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <roleManager enabled="true" defaultProvider="SqlRoleManager">
      <providers>
        <clear/>
        <add name="SqlRoleManager" type="System.Web.Security.SqlRoleProvider" connectionStringName="DefaultConnection" applicationName="-snip-"/>
      </providers>
    </roleManager>
    <httpRuntime/>
    <authentication mode="Windows">
      <forms loginUrl="~/Account/Login" timeout="2880"/>
    </authentication>
    <pages controlRenderingCompatibilityVersion="4.0">
      <namespaces>
        <add namespace="System.Web.Helpers"/>
        <add namespace="System.Web.Mvc"/>
        <add namespace="System.Web.Mvc.Ajax"/>
        <add namespace="System.Web.Mvc.Html"/>
        <add namespace="System.Web.Optimization"/>
        <add namespace="System.Web.Routing"/>
        <add namespace="System.Web.WebPages"/>
        <add namespace="Kendo.Mvc.UI"/>
      </namespaces>
    </pages>
    
  <httpModules>
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>
    </httpModules></system.web>
  
  <system.net>
    <mailSettings>
      <!-- snip -->
    </mailSettings>
    
    
  <defaultProxy enabled="true"/><settings>
			<!-- This setting causes .NET to check certificate revocation lists (CRL) 
			     before trusting HTTPS certificates.  But this setting tends to not 
			     be allowed in shared hosting environments. -->
			<!--<servicePointManager checkCertificateRevocationList="true"/>-->
		</settings></system.net>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
			<dependentAssembly>
				<assemblyIdentity name="System.Web.WebPages.Deployment" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
				<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
			</dependentAssembly>
			<dependentAssembly>
				<assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780CCD10D57B246" culture="neutral"/>
				<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0"/>
			</dependentAssembly>
			<dependentAssembly>
				<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
				<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
			</dependentAssembly>
			<dependentAssembly>
				<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30AD4FE6B2A6AEED" culture="neutral"/>
				<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
			</dependentAssembly>
			<dependentAssembly>
				<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="EB42632606E9261F" culture="neutral"/>
				<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2"/>
			</dependentAssembly>
			<dependentAssembly>
				<assemblyIdentity name="WebGrease" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
				<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930"/>
			</dependentAssembly>
			<dependentAssembly>
				<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
				<bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0"/>
			</dependentAssembly>
			<dependentAssembly>
				<assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780CCD10D57B246" culture="neutral"/>
				<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0"/>
			</dependentAssembly>
			
    </assemblyBinding>
    </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0"/>
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
    </providers>
  </entityFramework>
  <elmah>
    
    
  <!--
        See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for 
        more information on remote access and securing ELMAH.
    --><security allowRemoteAccess="false"/></elmah>
  <location path="elmah.axd" inheritInChildApplications="false">
    
    <system.webServer>
      
      <modules runAllManagedModulesForAllRequests="true">
        <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
        <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>
        <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>
      </modules>
    <handlers>
        <add name="ELMAH" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode"/>
      </handlers></system.webServer>
  <system.web>
      <httpHandlers>
        <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/>
      </httpHandlers>
      <!-- 
        See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for 
        more information on using ASP.NET authorization securing ELMAH.

      <authorization>
        <allow roles="admin" />
        <deny users="*" />  
      </authorization>
      -->  
    </system.web></location>
  
  
<dotNetOpenAuth>
		<messaging>
			<untrustedWebRequest>
				<whitelistHosts>
					<!-- Uncomment to enable communication with localhost (should generally not activate in production!) -->
					<!--<add name="localhost" />-->
				</whitelistHosts>
			</untrustedWebRequest>
		</messaging>
		<!-- Allow DotNetOpenAuth to publish usage statistics to library authors to improve the library. -->
		<reporting enabled="true"/>
	<!-- This is an optional configuration section where aspects of dotnetopenauth can be customized. --><!-- For a complete set of configuration options see http://www.dotnetopenauth.net/developers/code-snippets/configuration-options/ --><openid>
		<relyingParty>
				<security requireSsl="false">
					<!-- Uncomment the trustedProviders tag if your relying party should only accept positive assertions from a closed set of OpenID Providers. -->
					<!--<trustedProviders rejectAssertionsFromUntrustedProviders="true">
						<add endpoint="https://www.google.com/accounts/o8/ud" />
					</trustedProviders>-->
				</security>
				<behaviors>
					<!-- The following OPTIONAL behavior allows RPs to use SREG only, but be compatible
					     with OPs that use Attribute Exchange (in various formats). -->
					<add type="DotNetOpenAuth.OpenId.RelyingParty.Behaviors.AXFetchAsSregTransform, DotNetOpenAuth.OpenId.RelyingParty"/>
				</behaviors>
			</relyingParty></openid></dotNetOpenAuth><uri>
		<!-- The uri section is necessary to turn on .NET 3.5 support for IDN (international domain names),
		     which is necessary for OpenID urls with unicode characters in the domain/host name.
		     It is also required to put the Uri class into RFC 3986 escaping mode, which OpenID and OAuth require. -->
		<idn enabled="All"/>
		<iriParsing enabled="true"/>
	</uri><system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules>
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler"/>
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler"/>
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler"/>
    </modules>
  <handlers>
    <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
    <remove name="OPTIONSVerbHandler" />
    <remove name="TRACEVerbHandler" />
    <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
  </handlers></system.webServer></configuration>
Posted
Updated 5-Jan-21 10:27am
Comments
virang_21 6-Nov-14 17:13pm
   
<compilation debug="true" targetframework="4.5">

see if changing targetFramework to 4 makes any difference . Just a guess.
loctrice 7-Nov-14 8:54am
   
I gave it a shot. It caused a lot of errors that I can't work out now. I've been working on it for a couple of hours after updating my nuget packages. I'm not sure this is any better

1 solution

I fixed this by creating a new mvc4 project, and then installing the necessary nuget packages. It wasn't the way I wanted to go about it, but after days of searching this is what was recommended to me on another site.

This was a problem with using the Update-Package -reinstall command in nuget. It created dependancy package issues with the target framework.

One of the main things I noticed was in my views/config file

XML
<configsections>
    <sectiongroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirepermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirepermission="false" />
    </sectiongroup></configsections>


was changed to

XML
<configsections>
    <sectiongroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirepermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirepermission="false" />
    </sectiongroup>
  </configsections>


my main bindings changed from:

XML
<assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">
			<dependentassembly>
				<assemblyidentity name="System.Web.WebPages.Deployment" publickeytoken="31BF3856AD364E35" culture="neutral" />
				<bindingredirect oldversion="0.0.0.0-3.0.0.0" newversion="3.0.0.0" />
			</dependentassembly>
			<dependentassembly>
				<assemblyidentity name="DotNetOpenAuth.Core" publickeytoken="2780CCD10D57B246" culture="neutral" />
				<bindingredirect oldversion="0.0.0.0-4.3.0.0" newversion="4.3.0.0" />
			</dependentassembly>
			<dependentassembly>
				<assemblyidentity name="System.Web.WebPages" publickeytoken="31BF3856AD364E35" culture="neutral" />
				<bindingredirect oldversion="0.0.0.0-3.0.0.0" newversion="3.0.0.0" />
			</dependentassembly>
			<dependentassembly>
				<assemblyidentity name="Newtonsoft.Json" publickeytoken="30AD4FE6B2A6AEED" culture="neutral" />
				<bindingredirect oldversion="0.0.0.0-6.0.0.0" newversion="6.0.0.0" />
			</dependentassembly>
			<dependentassembly>
				<assemblyidentity name="Antlr3.Runtime" publickeytoken="EB42632606E9261F" culture="neutral" />
				<bindingredirect oldversion="0.0.0.0-3.5.0.2" newversion="3.5.0.2" />
			</dependentassembly>
			<dependentassembly>
				<assemblyidentity name="WebGrease" publickeytoken="31BF3856AD364E35" culture="neutral" />
				<bindingredirect oldversion="0.0.0.0-1.6.5135.21930" newversion="1.6.5135.21930" />
			</dependentassembly>
			<dependentassembly>
				<assemblyidentity name="System.Web.Mvc" publickeytoken="31BF3856AD364E35" culture="neutral" />
				<bindingredirect oldversion="0.0.0.0-5.2.2.0" newversion="5.2.2.0" />
			</dependentassembly>
			<dependentassembly>
				<assemblyidentity name="DotNetOpenAuth.AspNet" publickeytoken="2780CCD10D57B246" culture="neutral" />
				<bindingredirect oldversion="0.0.0.0-4.3.0.0" newversion="4.3.0.0" />
			</dependentassembly>
			
    </assemblybinding>



to


XML
<assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentassembly>
        <assemblyidentity name="DotNetOpenAuth.Core" publickeytoken="2780ccd10d57b246" />
        <bindingredirect oldversion="0.0.0.0-4.1.0.0" newversion="4.1.0.0" />
      </dependentassembly>
      <dependentassembly>
        <assemblyidentity name="DotNetOpenAuth.AspNet" publickeytoken="2780ccd10d57b246" />
        <bindingredirect oldversion="0.0.0.0-4.1.0.0" newversion="4.1.0.0" />
      </dependentassembly>
      <dependentassembly>
        <assemblyidentity name="System.Web.Helpers" publickeytoken="31bf3856ad364e35" />
        <bindingredirect oldversion="1.0.0.0-2.0.0.0" newversion="2.0.0.0" />
      </dependentassembly>
      <dependentassembly>
        <assemblyidentity name="System.Web.Mvc" publickeytoken="31bf3856ad364e35" />
        <bindingredirect oldversion="0.0.0.0-4.0.0.0" newversion="4.0.0.0" />
      </dependentassembly>
      <dependentassembly>
        <assemblyidentity name="System.Web.WebPages" publickeytoken="31bf3856ad364e35" />
        <bindingredirect oldversion="0.0.0.0-2.0.0.0" newversion="2.0.0.0" />
      </dependentassembly>
      <dependentassembly>
        <assemblyidentity name="WebGrease" publickeytoken="31bf3856ad364e35" />
        <bindingredirect oldversion="0.0.0.0-1.3.0.0" newversion="1.3.0.0" />
      </dependentassembly>
      <dependentassembly>
        <assemblyidentity name="EntityFramework" publickeytoken="b77a5c561934e089" culture="neutral" />
        <bindingredirect oldversion="0.0.0.0-5.0.0.0" newversion="5.0.0.0" />
      </dependentassembly>
    </assemblybinding>
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900