Sitefinity 8.1 - System.Web.HttpCompileException, The type or namespace name 'Mvc' could not be found (are you missing a using directive or an assembly reference
Hi, I thought I'd share an issue I was facing and my solution.
Setup:
* VS2012,
* Sitefinity 8.1 with Feather module installed
* using Telerkik.Sitefinity.All nuget packages instead of relying on default bin folder assemblies
* Hosted in IIS (not using IIS Express)
* Added a custom widget to SitefinityWebApp by referencing external assembly
* My custom widget uses an embedded razor view (Index.cshtml Build Action:embedded resource)
I followed feather tutorial but kept getting and error (in Error.log) when dropping the widget on to a page:
Type : System.Web.HttpCompileException, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Message : c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\0b3d364d\789bd827\App_Web_index.cshtml#bootstrap.cshtml.4c64411f.5msnie6e.0.cs(28): error CS0246: The type or namespace name 'Mvc' could not be found (are you missing a using directive or an assembly reference?)
After trial and error (hours) and numerous nuget Uninstall and Install-Package it turned out to be quite a simple fix.
Solution: Always Include the fully qualified name in your razor view when referencing your model in a custom external library. Resharper suggested I can remove the fully qualified path which introduced the issue.
For example :Index.cshtml
Wrong: @model Mvc.Models.MyWidget
Correct: @model MyCompany.Sitefinity.Frontend.MyWidgets.Mvc.Models.MyWidget
Hi Joe,
Thank you for the shared solution.
In addition, more information about how to create MVC widget in a separate assembly could be found here:
http://docs.sitefinity.com/feather-create-widgets.
Regards,
Svetoslav Manchev
Telerik