Oh, I faced with such problem while adding Razor Engine to my custom dll project. To solve this you have to:
1.correctly setup namespaces in web config file(hope you have it in views folder, if not - copy from MVC project):
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.Optimization" />
</namespaces>
</pages>
</system.web.webPages.razor>
...
2.use to build into bin\
path(not any other, you may use copy post-build command to move results to another place)
3.clean solution and remove obj
and bin
folders, than build
My views' code starts from @model MyModelClass
and all works fine
Model
, notmodel
) – Isley@{ var someValue = model.SomeProperty; }
in which case it needs to beModel.SomeProperty
(capital M) – Isleyin the section <system.web.webPages.razor>
– Crippen