How to add bundling and minification to an ASP.NET MVC project?

≯℡__Kan透↙ 提交于 2019-12-24 07:28:05

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/11936005/how-to-add-bundling-and-minification-to-an-asp-net-mvc-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!