1

I have just upgraded an ASP.NET MVC 3 project to MVC 4, and am now trying to add bundling and minification facilities to it. So far I have installed Microsoft ASP.NET Web Optimization Framework via NuGet and added System.Web.Optimization among the Razor namespaces in Web.config:

<system.web>
  ...
  <pages>
    <namespaces>
      ...
      <add namespace="System.Web.Optimization" />
      ...
    </namespaces>
  </pages>
  ...
</system.web>

However, @Styles and @Scripts are still not directly accessible in my Razor views (*.cshtml), I am forced to prefix them with the System.Web.Optimization namespace. Any clues as to what I'm missing?

0

1 Answer 1

4

In which web.config did you add the namespace? There is one in the views folder and another in the root of project. You have to add the namespace in both.

Sign up to request clarification or add additional context in comments.

4 Comments

Ah, that could well be it. I only added modified the root one. Will try your suggestion tomorrow.
Ok. Good look. Don't forget restart the Visual Studio if that don't work successfully
@vfabre why I must restart the Visual Studio after adding namespace to web.config?
@amirhosseinab I don't know why exactly, but sometimes they don't recognize the new namespaces.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.