MVC 4 Error: CS0103: The name ‘Scripts’ does not exist in the current context

Today, I was creating a MVC 4 web application. On building the project, I got an error “CS0103: The name ‘Scripts’ does not exist in the current context“. After analyzing, I figured out the problem is because of the namespace System.Web.Optimization was not added to the Web.config file in the view folder. After adding the namespace, the error vanished.

System.Web.OptimizationĀ is used for bundling and minifying js and css files. By bundling and minimizing the file size, this class improves the performance of the ASP.NET Web Forms and MVC applications. This namespace is provided by Microsoft. You can download the namespace from NuGet. In NuGet search forĀ Optimization. In the search result you can see the packageĀ Microsoft ASP.NET Web Optimization Framework.

If you find similar error, follow the below steps to trouble shoot and fix the error.

MVC-4-Error-CS0103-01

Troubleshooting MVC ErrorĀ Ā ‘Scripts’ does not exist in the current context:

  1. Check whether the namespaceĀ System.Web.OptimizationĀ is in the reference list.
    MVC-4-Error-CS0103-03
  2. If it’s not found in the reference list, then install it from NuGet. Right click the project and select Manage NuGet Packages…. In the Manage NuGet screen, search forĀ Optimization. From the result screen install the packageĀ Microsoft ASP.NET Web Optimization Framework.
    MVC-4-Error-CS0103-02
  3. Then open the Web.config file in the View folder. look for the name spaceĀ System.Web.OptimizationĀ in the <namespaces> section. Add the section if it is not there.
    MVC-4-Error-CS0103-04

Related Articles & Tools

2 comments for “MVC 4 Error: CS0103: The name ‘Scripts’ does not exist in the current context

  1. Jan 10, 2014 at 4:37 pm

    I now it’s going to sound stupid, but check if you have your

    namespace MainApp
    {
    public class BundleConfig

    BundleConfig class, you won’t be able to see anything in your HTML if you do not have this class, also, in your global.asax check that you have.
    BundleConfig.RegisterBundles(BundleTable.Bundles); on your app_start method.

    Have fun!

  2. Monte
    Sep 3, 2013 at 3:19 pm

    Did that…didnt work. I still get the error, I have the ref, and I have the namespace added in the config file in the Views folder….now what.

Leave your thoughts...