Search code examples
asp.net-mvcasp.net-mvc-5

MVC 5- Application showing error message for System.Web.WebPages.Html.HtmlHelper for controls like viewbag


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???


Solution

  • 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.