CS0103: The name ‘Scripts’ does not exist in the current context解决方法
2014-11-10 20:19
1016 查看
转至:http://blchen.com/cs0103-the-name-scripts-does-not-exist-in-the-current-context-solution/
更新:这个bug在ASP.NET MVC 4正式版已经没有了。
今天试玩VS2012里的ASP.NET MVC4,用Controller里用Entity Framework生成模版后,发现页面报错CS0103: The name ‘Scripts’ does not exist in the current context。
看了一下原因是MVC4里自动生成的cshtml里都会自动包含下面几行js脚本引用
@section Scripts {
@Scripts.Render(“~/bundles/jqueryval”)
}
@Styles和@Scripts是MVC4里新加的位于System.Web.Optimization下的辅助类,主要用于将多个CSS和JavaScript脚本文件压缩并打包成单个文件。如果项目里没有对System.Web.Optimization,则上面code编译无法通过。
解决方法:在NuGet包管理器里搜索Optimization,安装完毕后在MVC4的web.config里namespace节点下多加一行<add namespace=”System.Web.Optimization” />。
更新:这个bug在ASP.NET MVC 4正式版已经没有了。
今天试玩VS2012里的ASP.NET MVC4,用Controller里用Entity Framework生成模版后,发现页面报错CS0103: The name ‘Scripts’ does not exist in the current context。
看了一下原因是MVC4里自动生成的cshtml里都会自动包含下面几行js脚本引用
@section Scripts {
@Scripts.Render(“~/bundles/jqueryval”)
}
@Styles和@Scripts是MVC4里新加的位于System.Web.Optimization下的辅助类,主要用于将多个CSS和JavaScript脚本文件压缩并打包成单个文件。如果项目里没有对System.Web.Optimization,则上面code编译无法通过。
解决方法:在NuGet包管理器里搜索Optimization,安装完毕后在MVC4的web.config里namespace节点下多加一行<add namespace=”System.Web.Optimization” />。
相关文章推荐
- Error:The name 'Encoding' does not exist in the current context 解决方法
- 解决办法:The name 'Response' does not exist in the current context
- 如何解决 The name ControlID does not exist in the current context 错误!
- 关于编写WPF UserControl时提示The name 'InitializeComponent' does not exist in the current contextr的解决!
- The name 'xxx' does not exist in the current context 錯誤解決方法之一
- Unity 错误(1)——The name `xxx' does not exist in the current context
- The name does not exist in the current context
- error CS0103: The name `UnityEditor' does not exist in the current context
- Error:The type or namespace name 'Office' does not exist in the namespace 'Microsoft' 解决方法
- The name ‘InitialzeComponent’ does not exist in the current context
- The name 'Profile' does not exist in the current context
- Unity3d 提示 "The scripts file name does not match the name of the class defined in the script!"的解决办法
- The name 'Scripts' does not exist in the current context error in MVC
- The project: nameXXX which is referenced by the classpath, does not exist解决方法?
- 解决The type or namespace name \'XXXX\' does not exist in the namespace \'XXXXXXXXX\' 的错误
- wpf程序报"The name 'InitializeComponent' does not exist in the current context"的
- The type or namespace name 'Zhaopin' does not exist in the namespace 'LMSoft' 问题的解决
- The name 'AccordionLayout1' does not exist in the current
- InitializeComponent does not exist in the current context
- 关于The target "GetCopyToOutputDirectoryContentProjectItems" does not exist in the project.的解决方法