4
votes

I upgrade the visual studio 2010 MVC project to visual studio 2013 .Net 4.5.

When I tried to add the following declaration to it, I get an error:

The type arguments for method 'System.Web.Mvc.Html.InputExtensions.PasswordFor(System.Web.Mvc.HtmlHelper, System.Linq.Expressions.Expression>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

I checked the references, all of them are in place. I added an web.config in view folder, but that didn't fix it.

enter image description here

Is there anything i am missing?

2
Do you have the correct information in the web.config you placed in your view folder? There are some important sections that missing would cause this error. - Tommy
I recommend you create a new MVC project in VS2013 and compare web.configs (website root & the one under the Views folder) and the referenced assemblies and you make the proper adjustments to the migrated project. This is the approach I use. - epignosisx
Check your View's web.config <system.web.webPages.razor> under <namespaces>. Usually you get this compile errors when you are missing <add namespace="System.Web.Mvc.Html" />. - Spock

2 Answers

1
votes

After upgrading to MVC 5.1 I had a similar problem, fixed by updating the version of System.Web.WebPages.Razor from 2.0.0.0 to 3.0.0.0 in the config section of views\web.config

<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>
0
votes

Visual studio 2013 does nto support MVC3, only MVC 4:

Visual Studio 2013 Compatibility

Visual Studio 2010 SP1 supports only MVC 2 and MVC 3, Visual Studio 2012 supports only MVC 3 and MVC 4, and Visual Studio 2013 supports only MVC 4

This is why your getting these errors. You need to follow the instructions to upgrade your MVC3 project to MVC 4