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>
但问题是它说当前上下文中不存在名称脚本"
.
我已经将程序集添加到引用和捆绑配置中作为 using System.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?
推荐答案
确保您的 ~/Views/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屋!
查看全文