Although many projects have been done with MVC, they are implemented in the framework of others.
Today came across a very simple namespace reference problem
, scripts and styles do not reference namespaces
Workaround One:
Direct use of System.Web.Optimization.Scripts and System.Web.Optimization.Styles, this method is not practical, too troublesome
Workaround Two:
Adding using System.Web.Optimization to the layout head; It's tedious to add it on every page of the layout.
Solution Three:
Add namespaces to the <system.web></system.web> of Web. config
<pages> <namespaces> <addnamespace="System.Web.Helpers"/> <addnamespace="SYSTEM.WEB.MVC"/> <addnamespace="System.Web.Mvc.Ajax"/> <addnamespace="System.Web.Mvc.Html"/> <addnamespace="System.Web.Routing"/> <addnamespace="System.Web.WebPages"/>
<addnamespace="System.Web.Optimization"/> </namespaces> </pages>
This is once and for all, the problem is small, cut let me realize the importance of seeking the bottom of the root
MVC Layout Namespace Reference problem