The name 'Styles' does not exist in the current context The name 'Scripts' does not exist in the current context


When i insert  @Styles.Render("~/
Content/themes/base/css", "~/Content/css")  @Scripts.Render("~/bundles/modernizr")  in my MVC 4 Empty project i get the following error The name 'Styles' does not exist in the current context
The name 'Scripts' does not exist in the current context

Solution

Open Web.config file from view/web.config
 and add the namespace "System.Web.Optimization" under namespace tag
  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.
MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.
WebViewPage">
      <namespaces>       .
       .
       .
        <add namespace="System.Web.
Optimization" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>



Similarly open root/web.config file and do above changes
 Then restart the procet

1 comment: