0

Yes I've searched the rest of s.o. for a solution, none of those solutions worked for me. Here's the issue:

1) Visual Studio 2012 -> New Web Site...

2) create a normal MVC 4 site (Razor v2) and .NET 4.5

3) add the following code to Default.cshtml

@using (Html.BeginForm())
{

}

4) launch and get this error:

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

What gives?

EDIT, uploaded my website here as a zip, only 276K: http://budzap.com/mvc.zip

5
  • It would help if you listed what's been tried: using statement exists, cleaned solution, removed .user project file, NUGET restore, etc. stackoverflow.com/questions/12692011/… Commented Apr 22, 2015 at 19:57
  • have you tried updating the web.config as seen here stackoverflow.com/questions/12041633/… Commented Apr 22, 2015 at 20:35
  • I tried about 20 various solutions across s.o., so didn't want to list them all but really nothing has helped. Tried goldeneye's fix but no effect. Added a link to a zip of my website, maybe someone can try running it real quick and get the same error. Commented Apr 23, 2015 at 15:51
  • Could u create solution and upload to the site. Commented Apr 23, 2015 at 15:55
  • Did already, it's at the bottom of the question, here too: budzap.com/mvc.zip Commented Apr 23, 2015 at 19:02

3 Answers 3

2

Make sure that the Razor version number in Views > Web.config match each other.

<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0 [etc]

and

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0 [etc]
Sign up to request clarification or add additional context in comments.

2 Comments

heh about 4 years too late, we don't even use BeginForm anymore but thx
@Huge you are right - this is the case for me - System.Web.WebPages.Razor is 3.0.0.0 while System.Web.MvcSystem.Web.Mvc is 4.0.0.0 but how do I fix it? the PM says both are latest and just change manually gives of course an error. Thanks.
0

This message says the version of your System.Web.Mvc does not support BeginForm.It may have many causes.To find out the cause your problem,you can try one of this:

  • It is usaually caused by deleting the second web.confing which resides in the view folder.see this

  • See the version of your System.Web.Mvc in References of your project.it might be an old version that doesnot support BeginForm.

  • add System.Web.Mvc.html before BeginForm to see if there is such a method.

1 Comment

This is too speculative to be an answer. It should be a comment at most.
-2

Move your _layoutPage into the Views folder

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.