名称'脚本'不存在于MVC当前上下文 [英] The name 'Scripts' does not exists in the current context in MVC
本文介绍了名称'脚本'不存在于MVC当前上下文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的MVC应用程序,在_Layout.cshtml有下面的代码...
In my mvc application, In the _Layout.cshtml has code below...
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
但问题是,它说名称'脚本'不存在当前上下文
。
我已经添加了组件的参考和使用系统的捆绑配置为。 Web.Optimization;
I have already added the assembly to the reference and to the Bundle config as using System.Web.Optimization;
这里面有 @styles 也..
我应该怎么办?
This happens for @styles also.. What should I do?
推荐答案
请确保您的〜/查看/ Web.Config中
添加 System.Web.Optimization
命名空间:
Make sure your ~/Views/Web.Config
adds the System.Web.Optimization
namespace:
<system.web.webPages.razor>
<pages>
<namespaces>
<add namespace="System.Web.Optimization"/>
</namespaces>
</pages>
</system.web.webPages.razor>
这篇关于名称'脚本'不存在于MVC当前上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文