Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make intellisense works with RazorEngine?

Tags:

I am trying to configure RazorEngine so that intellisense works on views. I add RazorEngine and Microsoft.AspNet.Mvc using nuget. I create TestView.cshtml and declare @model MyModel but it says The name 'model' does not exist in the current context. I also cannot use intellisense inside the view.

Do I miss any step here? How to enable intellisense in the View?

like image 798
Anonymous Avatar asked Nov 11 '14 10:11

Anonymous


1 Answers

You can use

@using RazorEngine.Templating @using Namespace.Of.My.Model @inherits TemplateBase<MyModel> 

on the top of your template.

This works fine on a new Console Application with Visual Studio 2013 (after adding a reference to RazorEngine). The documentation for this is here.

EDIT:

I noticed that this only works when the RazorEngine project is added to the solution and directly referenced. If you use the NuGet package you additionally need to ensure one of the following to make it work:

  1. Your project output path is set to bin\ instead of bin\Debug\ and bin\Release\.
  2. Copy RazorEngine.dll and System.Web.Razor.dll to bin\
like image 58
matthid Avatar answered Oct 06 '22 01:10

matthid