Tuesday, May 28, 2013

MVC Error : CS0103: The name 'Scripts' does not exist in the current context



CS0103: The name 'Scripts' does not exist in the current context



Source Error:

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}


The solution is

1. Also install  "Microsoft ASP.NET Web Optimization Framework" package from NuGet
2. Include <add namespace="System.Web.Optimization"> in both web.configs.


Views Web.config

    <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.Optimization"/>
        <add namespace="System.Web.Helpers"/>
      </namespaces>


Root Web.config


      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
        <add namespace="System.Web.Optimization"/>      
      </namespaces>






















No comments:

Post a Comment