Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC 3 project rejects requests for Razor views with CS0103: The name 'model' does not exist

I have and MVC3 project that once upon a time was an MVC2 project. I've been developing it using IIS express to test. Now I deployed it to IIS proper on my machine, jiggled some web.config settings, and messed around for an hour getting the razor build provider to be registered, which must not be done right because the new project template doesn't include a line adding that build provider in the web.config.

At any rate, any time I go to a strongly-typed Razor view I get this:

Compiler Error Message: CS0103: The name 'model' does not exist in the current context

Source Error:

Line 1:  @model Cairn.Cartography.Features.Peak

Any thoughts on what is going on, and how I might fix it without firebombing this box and looking around for my windows install cd? :)

like image 735
Doug McClean Avatar asked Apr 02 '11 22:04

Doug McClean


2 Answers

I was missing:

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

in this part of my web.config file:

<system.web.webPages.razor>
  <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  <pages pageBaseType="System.Web.Mvc.WebViewPage">
    <namespaces>
      <add namespace="Cairn"/>
      <add namespace="Cairn.UI.Web"/>
      <add namespace="Cairn.UI.Web.Helpers"/>
    </namespaces>
  </pages>
</system.web.webPages.razor>

I haven't the foggiest what this means or why it matters, or why it is absent from the web.config generated for a brand new project, but it works.

? Oh well

like image 159
Doug McClean Avatar answered Oct 19 '22 01:10

Doug McClean


yes.. reinstall asp.net MVC3 again

either get the MSI file from here: http://go.microsoft.com/fwlink/?LinkID=208140

or use Web Platform Installer from here: http://www.microsoft.com/web/gallery/install.aspx?appid=MVC3

like image 41
Mohammed Swillam Avatar answered Oct 19 '22 03:10

Mohammed Swillam