如何使智能感知与RazorEngine一起使用? [英] How to make intellisense works with RazorEngine?

查看:71
本文介绍了如何使智能感知与RazorEngine一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试配置RazorEngine,以使intellisense在视图上起作用.我使用nuget添加RazorEngine和Microsoft.AspNet.Mvc.我创建了TestView.cshtml并声明了@model MyModel,但它显示了The name 'model' does not exist in the current context.我也不能在视图内部使用智能感知.

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?

推荐答案

您可以使用

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

位于模板顶部.

这在带有Visual Studio 2013的新控制台应用程序上正常工作(添加对RazorEngine的引用之后). 有关文档,请此处.

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

我注意到这仅在将RazorEngine项目添加到解决方案并直接引用时才有效.如果您使用NuGet软件包,则还需要确保以下条件之一使其起作用:

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. 您的项目输出路径设置为bin\,而不是bin\Debug\bin\Release\.
  2. RazorEngine.dllSystem.Web.Razor.dll复制到bin\
  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\

这篇关于如何使智能感知与RazorEngine一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆