Search code examples
c#razorhelperbundling-and-minification

Cannot have access to @Styles and @Scripts Helper in MVC


I cannot get access to The helper @Styles nor @Scripts. I have added <add namespace="System.Web.Optimization" /> as proposed HERE and HERE. I use to have this problem, but i solved it by adding @using System.Web.Optimisation

Here are my configs (the relevant part):

 <system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
  <namespaces>
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Optimisation" />
    <add namespace="System.Web.Routing" />
    <add namespace="CariSSC" />
  </namespaces>
</pages>

I read a couple of blogs online and they all point to the same solution. Any clues on how to fix this?


Solution

  • You misspelled Optimization namespace in your config file. You have Optimisation when it should be Optimization.