Fix Visual Studio 2013 Razor CSHTML Intellisense in Class Library or Console Application

I tried to use a .cshtml file and the razor syntax in a console application. I was able to build the project, but the intellisense and the error tab complaint about „The name ‚Model‘ does not exist in the current context„:


The usual fixes, like throwing in a web.config, didn’t work. But then I found a fix to solve that problem. Here are the steps:

  • make sure you have the Microsoft ASP.NET MVC nuget package and its dependecies installed
  • clean and build your project, close your .cshtml-files
  • copy the following DLLs from Debug (or the mode you’re in) right to the bin folder
    • Microsoft.Web.Infrastructure.dll
    • System.Web.Helpers.dll
    • System.Web.Mvc.dll
    • System.Web.Razor.dll
    • System.Web.WebPages.Deployment.dll
    • System.Web.WebPages.dll
    • System.Web.WebPages.Razor.dll


  • open your .cshtml file
  • it should work

Reason: I guess it’s because in a normal web project there is only a bin folder, no Debug or Release. Visual Studio seems to look directly into that folder for it’s tooling/Intellisense. But I can’t confirm that, it’s just a guess 😉


Edit 2014-10-20:

If you need to use @Html.Raw(), just type @Raw(). The Intellisense doesn’t work for it, but in my case the rendered result was as expected.

Dieser Beitrag wurde unter ASP.NET MVC, Razor, Visual Studio veröffentlicht. Setze ein Lesezeichen auf den Permalink.

Eine Antwort zu Fix Visual Studio 2013 Razor CSHTML Intellisense in Class Library or Console Application

  1. mhusseini schreibt:

    Thank you. This worked great!

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

Du kommentierst mit Deinem Abmelden / Ändern )


Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )


Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s