0

I have an existing MVC Project which i have Upgraded to MVC 5 .I have used Visual Studio Package Manager to update existing Packages installed.

'System.Web.WebPages.Html.HtmlHelper' does not contain a definition for 'BeginForm' and no extension method 'BeginForm' 

Issue is same for other controls like action links too. I have followed the approach mentioned for Upgrading MVC project and made necessary webconfig amendments. Application is not showing intellisence. errors are thrown if i keep view open. More over if i close the view and build application no errors are thrown without any errors. Run properly.

Do Read the post carefully before marking it for similar existing posts. I have already tried few existing solutions provided on stackoverflow.

I am mentioning few links here System.Web.Mvc.HtmlHelper' does not contain a definition for 'ActionLink' stackoverflow.com/questions/12041633/razor-views-not-seeing-system-web-mvc-htmlhelper

http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2

Please do guide what exactly i am missing any references???

Community
  • 1
  • 1
gt3
  • 1
  • 1
  • 4

2 Answers2

1

You should have following assemblies in your web.config file (In your Views folder):

In configSections tag:

<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.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>

In system.web.webPages.razor tag:

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.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="GildenhuisHoboken2014" />
  </namespaces>
</pages>

</system.web.webPages.razor>

Jake
  • 7,565
  • 6
  • 55
  • 68
Jelle Oosterbosch
  • 1,731
  • 15
  • 17
  • When i updated i changed version for System.Web.WebPages.Razor 3.1.0.0 which was installed during updated System.Web.Mvc version 5.1.0.0. But i donot have GildenhuisHoboken2014 in my webconfig what is it for ? I already mentioned it in the above upgrade link that i followed. – gt3 Jan 24 '14 at 11:50
  • I am trying on VS2013. I have updated almost all the packages but somehow it is still showing me errors for System.Web.WebPages.Html.HtmlHelper – gt3 Jan 24 '14 at 12:34
  • GildenhuisHoboken2014 is something variable for me. I'll keep looking. – Jelle Oosterbosch Jan 24 '14 at 12:50
-5

Ok i have fixed it in appsetting it should have a tag

webpages version should be 3.0.0.0

web page and Razor version should be 3.0 not 3.1

mvc 5.1.0.0

You do need to specify the dependent assemble for older tags

do not use upgrade package command. use Manage NuGet Package Manager Interface as just update required stable versions.

Latest supported version for mvc5 should be used for all the packages in use.

gt3
  • 1
  • 1
  • 4