转至: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” />。

CS0103: The name ‘Scripts’ does not exist in the current context解决方法的更多相关文章

  1. The name 'Scripts' does not exist in the current context error in MVC

    创建完成ASP.NET MVC4应用程序以后,试着运行其中一个Create页面, 程序报出运行是错误: CS0103: The name 'Scripts' does not exist in  th ...

  2. MVC:The name 'Scripts' does not exist in the current context

    汇总:http://www.cnblogs.com/dunitian/p/4523006.html#efmvc 解决:在View下面的Web.Config的namespaces添加 <add n ...

  3. .ascx.g.cs文件不能生成 The name ‘InitializeControl’ does not exist in the current context - Visual Web part Sharepoint

    InitializeControl doesn't exsit When using visual studio 2012 for developing SharePoint 2013 Visual ...

  4. The name ‘InitialzeComponent’ does not exist in the current context

    在Visual Studio中创建Windows Store项目,在MainPage.xaml.cs中出现错误: The name 'InitialzeComponent' does not exis ...

  5. 启动Solr时报 _version_ field must exist in schema 错误的解决方法

    Solr启动时报 org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Unable to use up ...

  6. 关于method not exist:think\db\Query->render错误解决方法

    {volist name="Teachers" id="Teachers" key="key"} <tr> <td> ...

  7. vs 编译错误 The name 'InitializeComponent' does not exist in the current context in WPF application

    1:文件命名空间的问题 xaml文件和model.cs文件的命名空间 2:csproj 那么它究竟是给谁用的呢?那是给开发工具用的,例如我们在熟悉不过的Visual Studio,以及大家可以没有接触 ...

  8. flutter 运行别人项目 包无法导入报错:Target of URI doesn't exist 'package:flutter/material.dart' 解决方法

    命令行里运行  flutter packages get

  9. mysql 直接从date 文件夹备份表,还原数据库之后提示 table doesn`t exist的原因和解决方法

    补充:正常情况下,建议数据库备份最好用工具进行备份,通过拷贝数据库表进行数据迁移,不同的环境会出现各种不同的意外问题. 背景:今天在整理一个网站的时候,操作系统由于系统自动更新导致一直出现系统蓝屏死机 ...

随机推荐

  1. maven实战(04)_在pom中使用properties

    使用常量不仅让代码变得简洁,更重要的是可以避免重复,在需要更改的时候,只需要修改一处,降低了错误发生的概率. <project> <modelVersion>4.0.0< ...

  2. git error: unable to rewind rpc post data - try increasing http.postBuffer

    error: unable to rewind rpc post data - try increasing http.postBuffererror: RPC failed; curl 56 Rec ...

  3. Hadoop学习记录

    http://blog.csdn.net/m_star_jy_sy/article/details/26476907配置windows里eclipse连接hadoop集群 hadoop常见命令 启动H ...

  4. Java 动态代理机制详解

    在学习Spring的时候,我们知道Spring主要有两大思想,一个是IoC,另一个就是AOP,对于IoC,依赖注入就不用多说了,而对于Spring的核心AOP来说,我们不但要知道怎么通过AOP来满足的 ...

  5. 爬虫 htmlUnit遇到Cannot locate declared field class org.apache.http.impl.client.HttpClientBuilder.dnsResolve错误

    当在使用htmlUnit时遇到无法定位org.apache.http.impl.client.HttpClientBuilder.dnsResolver类时,此时所需要的依赖包为: <depen ...

  6. 【SqlServer】empty table and delete table and create table

    1.建表 1 IF object_id (N'表名', N'U') IS NULL CREATE TABLE 表名 ( 2 id INT IDENTITY (1, 1) PRIMARY KEY ,.. ...

  7. Linux 命令备忘录(CentOS 7)

    创建目录testdir: mkdir  testdir 进入目录testdir:cd testdir 在testdir中创建空文件 1:   touch 1 在testdir中创建空文件 2:   t ...

  8. rocketmq生产者和消费者

    1.生产者: package com.ebways.mq.test.mq; import com.alibaba.rocketmq.client.exception.MQClientException ...

  9. SQL Server 从数据库中查询去年的今天的数据的sql语句

    因为最近的项目的一个小功能需要实现当前数据和历史的今天做一个对比.在网上也查了很久,很多都是实现一个月内的,一年内的所有数据,昨晚突然就找到了下面的实现方法,在SQL Server2008中试了一下, ...

  10. iOS图表库Charts集成与使用

    Charts是一个很优秀的图表库,它支持Android.iOS.tvOS和macOS,这样使用起来,可以节省学习成本,可以从GitHub上了解更多信息.本文记录在iOS项目上的集成与使用. Chart ...