If you open an older ASP.Net MVC3 project in Visual Studio 2012, you may see lots of errors in the Razor views, along the lines of “The name 'model' does not exist in the current context”, and similar errors whenever you try to use MVC features like HTML helpers or ViewContext (eg, “System.Web.WebPages.Html.HtmlHelper does not contain a definition for TextBoxFor”).
This happens if there is no <add key="webpages:Version" value="1.0" />
in the <appSettings> element in Web.config.
Without this element, Visual Studio will assume that you’re using the latest version of Razor and the WebPages framework. Until VS2012, this wasn’t a problem, since there was only one version. However, since VS2012 ships with ASP.Net WebPages 2.0, the IDE will load this version by default. Since you’ve specified the MVC integration & <configSection> for 1.0 (in Views/Web.config, since all of the assembly references specify Version=1.0.0.0), the language services won’t load the MVC settings. Therefore, the @model
directive will not work, and the view will inherit the standard WebPage
base class rather than the MVC WebViewPage
base class (which contains the MVC HTML helpers)
This issue has no effect at runtime because the server won’t load any version 2.0 assemblies.
201 comments:
«Oldest ‹Older 201 – 201 of 201 Newer› Newest»Hello, I am Looking the Your Website. This is the Very Good blogging website.
When searching for the Best Price ESD foam for Your Sensitive Electronics and Components, Look No Further Than Gravofoam. Engineered for Superior Electrostatic Discharge Protection, Gravofoam Offers Exceptional Value Without Compromising on Quality or Performance.
ESD Foam Manufacturer Company
ESD Foam Sheet
ESD Foam Supplier
ESD Foam Roll
ESD Foam Material
ESD Foam Blocks
ESD Roll Sheet
Post a Comment