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?
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:
bin\
instead of bin\Debug\
and bin\Release\
.RazorEngine.dll
and System.Web.Razor.dll
to bin\
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With