该名称在当前上下文中不存在(剃刀) [英] The name does not exist in the current context (razor)

查看:37
本文介绍了该名称在当前上下文中不存在(剃刀)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在剃须刀方面遇到了一些问题,但又一次让我感到压力.

I'm having a few issues with razor and yet again it's stressing me out.

我打开了一个剃须刀内满是 Red Squiggles 的项目.这是一个很大的挑战,因为我是一名Webforms开发人员,正在向MVC过渡.

I opened a project which is littered with Red Squiggles within the razor. This is very much a challenge as I'm a Webforms developer moving over to MVC.

我正在运行Visual Studio 2015企业版.

I'm running visual studio 2015 enterprise.

起初,我认为这可能是版本问题,但一切似乎都不错.WebConfig似乎是最新的.我很茫然,需要指导.任何帮助,不胜感激!

At first I thought it might be a version issue but all seems good. WebConfig seems up to date. I'm at a loss, and in need of guidance. Any help greatly appreciated!

////编辑

查看web.config.

Views web.config.

  <add namespace="System.Web.Mvc" />
  <add namespace="System.Web.Mvc.Ajax" />
  <add namespace="System.Web.Mvc.Html" />
  <add namespace="System.Web.Routing" />
  <add namespace="System.Web.Optimization" />

似乎我缺少剃刀命名空间.我实际上不能在引用中添加它.

It looks like I'm missing the razor namespace. I cannot actually add this in the references.

推荐答案

在您的web.config中找到< system.web.webPages.razor> 部分.可以在视图"->"web.config"下找到此配置文件.如果您具有 System.Web.Mvc.MvcWebRazorHostFactory 4.0.0.0版,则将其更改为 Version = 5.0.0.0 .它应该如下所示:

Locate section <system.web.webPages.razor> in you web.config. This configuration file can be found under Views -> web.config. If you have version 4.0.0.0 for System.Web.Mvc.MvcWebRazorHostFactory then change it to Version=5.0.0.0. It should look like below:

< host factoryType ="System.Web.Mvc.MvcWebRazorHostFactory,System.Web.Mvc,Version = 5.0.0.0,Culture = neutral,PublicKeyToken = 31BF3856AD364E35"/>

注意:请确保您在Visual Studio中调用了所有视图并重新打开它们.

Note: Make sure you call all the views in Visual studio and re-open them.

这篇关于该名称在当前上下文中不存在(剃刀)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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